A elegant JavaScript alternative for in-memory documents
Imd.js (In Memory Documents
) is a powerful alternative library for saving data in memory.
- Remote sync;
- Fast and elegant;
- Easy integration and ready to use;
- Key or auto increased number in Document Identifiers;
This quick start guide shows you how to use the basic functions of the library in local use, for integrated server use cases visit the documentation...
Import, first we need to import the library
const Imdjs = require('imd.js')
Now, we need to instantiate before we do any operations
const MyDocuments = new Imdjs.default()
After we import and instantiate, here are examples of creating documents and getting them.
create(value, key?, timestamp?)
: Used to create a new document
const MyTextDocument = MyDocuments.create('Hello World!')
// => Document { _id: 1, content: "Hello World!", timestamp: "..." }
- [EXPERIMENTAL]
bulkCreate(value, key?)
: Used to create multiple documents in one time
MyDocuments.bulkCreate([
{
content: 'Hello World',
},
{
key: 'hello-world-in-portuguese',
content: 'Olá mundo',
},
])
// => [
// Document { _id: 1, content: "Hello World!", timestamp: "..." },
// Document { _id: "hello-world-in-portuguese", content: "Olá mundo!", timestamp: "..." },
// ]
rescue(identificator)
: Used to obtain a document
const MyTextDocument = MyDocuments.create('Hello World!')
MyDocuments.rescue(MyTextDocument._id)
// => Document { _id: 1, content: "Hello World!", timestamp: "..." }
remove(identificator)
: Used to delete a document
MyDocuments.remove('document-id')
// => true
Made with 💜 by Amélia R.