forked from platypush/platypush
Created two separate actions under variable
to delete/unset.
`delete` will actually remove the record from the database (same as `unset`'s new behaviour), while `unset` will set it to null without deleting it (same as the `unset`'s previous behaviour).
This commit is contained in:
parent
98b9d31dd4
commit
373788377b
1 changed files with 18 additions and 2 deletions
|
@ -57,9 +57,12 @@ class VariablePlugin(Plugin, EntityManager):
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
@action
|
@action
|
||||||
def unset(self, name: str):
|
def delete(self, name: str):
|
||||||
"""
|
"""
|
||||||
Unset a variable by name if it's set on the local db.
|
Delete a variable from the database.
|
||||||
|
|
||||||
|
Unlike :meth:`.unset`, this method actually deletes the record from the
|
||||||
|
database instead of setting it to null.
|
||||||
|
|
||||||
:param name: Name of the variable to remove.
|
:param name: Name of the variable to remove.
|
||||||
"""
|
"""
|
||||||
|
@ -72,6 +75,19 @@ class VariablePlugin(Plugin, EntityManager):
|
||||||
self._db_vars.pop(name, None)
|
self._db_vars.pop(name, None)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@action
|
||||||
|
def unset(self, name: str):
|
||||||
|
"""
|
||||||
|
Unset a variable by name if it's set on the local db.
|
||||||
|
|
||||||
|
Unlike :meth:`.delete`, this method only sets the record to null
|
||||||
|
instead of removing it from the database.
|
||||||
|
|
||||||
|
:param name: Name of the variable to remove.
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self.set(**{name: None})
|
||||||
|
|
||||||
@action
|
@action
|
||||||
def mget(self, name: str):
|
def mget(self, name: str):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue