Renames a key.
Last updated 1 year ago
db.set('people', ['Peter', 'Henry']); db.rename('people', 'users')); // { users: ['Peter', 'Henry'] };
Also allows the use of dot notation:
db.set('user', { id: 32171, items: ['sword'] }); db.rename('user.items', 'bag'); // { id: 32171, bag: ['sword'] }
db.set('posts', [{ title: 'My #1 post' }]); db.rename('posts', 'forum.posts'); // { forum: { posts: [{ title: 'My #1 post' }] } }
Parameter
Description
key
String
The target key
newName
The new name for the key
Returns
JSONData
The updated data from the provided key's root