easy-store
v0.1.3
Published
Easy file system JSON storage
Downloads
17
Readme
A simple storage mechanism for doing demos and stuff where you require some persistence. Only works in Node.
Install
yarn add easy-store
Use
import store from 'easy-store';
const users = store('users');
await users.create({name: 'Fart', email: '[email protected]'});
/*
{
id: 'SJb2pWGOAe',
name: 'Fart',
email: '[email protected]',
createdAt: 1492816324108,
updatedAt: 1492816324108
}
*/
await users.get('SJb2pWGOAe');
// { id: 'SJb2pWGOAe', ... }
await users.query()
// [{ id: 'SJb2pWGOAe', ... }]
await users.query(u => u.email === '[email protected]');
// [{ id: 'SJb2pWGOAe', ... }]
await users.update({id: 'SJb2pWGOAe', name: 'Next'});
// { id: 'SJb2pWGOAe', name: 'Next', ... }
await users.remove('SJb2pWGOAe')
// { id: 'SJb2pWGOAe' }