Sets a new value to the value of the provided key.
Last updated 3 years ago
Parameter
Default
Description
key
The target key
value
Any
The value to set
encrypt
false
Whether or not to encrypt the value before setting it
Returns
The updated data from the provided key's root
db.set('user', { name: 'Peter' }); // { name: 'Peter' } db.get('user'); // { name: 'Peter' }
Also allows the use of dot notation:
db.get('user'); // { name: 'Peter' } db.set('user.age', 19); // { name: 'Peter', age: 19 }