.set()

Sets a new value to the value of the provided key.

set(key, value, encrypt)

Parameter

Default

Description

key

String

The target key

value

Any

The value to set

encrypt

false

Boolean

Whether or not to encrypt the value before setting it

Returns

Description

Any

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 }

Last updated