{"_id":"nstore","_rev":"43-4c08f1ef9d831cc40c3835f291d383d1","name":"nstore","description":"nStore is a simple, in-process key/value database for node.js.","dist-tags":{"latest":"0.5.2"},"versions":{"0.3.0":{"name":"nstore","version":"0.3.0","description":"nStore is a simple, in-process key/value database for node.js.","tags":["nosql","database"],"author":{"name":"Tim Caswell","email":"tim@creationix.com"},"repository":{"type":"git","url":"http://github.com/creationix/nstore.git"},"bugs":"http://github.com/creationix/nstore/issues","engines":["node >= 0.2.0"],"modules":{"index":"lib/nstore.js","cache":"lib/nstore/cache.js","query":"lib/nstore/query.js"},"dependencies":{"step":">=0.0.3","pattern":">=0.0.2"},"_id":"nstore@0.3.0","_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/nstore/-/nstore-0.3.0.tgz","shasum":"ae5ea47eee4daae7ba1ca58800e5246f236df82e","integrity":"sha512-nd6i2gTVjWOi/NLzEvjSEof8qn67s/LTeMjtQJk3FfoZ7iHhLF6erTtSTn7SLmjbnml6EqvEs2bMKzJJif7fsg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHXBF89YmYLshD61J7W4I8ssDLzgbVEscDjGNKHXt0KaAiEAjcR8lych+yGuglIbcsNYN+G33LNIexf+3I2ICunGa6w="}]},"directories":{}},"0.4.0":{"name":"nstore","version":"0.4.0","description":"nStore is a simple, in-process key/value database for node.js.","tags":["nosql","database","pattern"],"author":{"name":"Tim Caswell","email":"tim@creationix.com"},"repository":{"type":"git","url":"git://github.com/creationix/nstore.git"},"bugs":{"name":"http://github.com/creationix/nstore/issues"},"engines":["node >= 0.4.0"],"main":"nstore.js","dependencies":{"step":">=0.0.3","pattern":">=0.2.0","pattern-hash":">=0.2.0","pattern-queue":">=0.2.0"},"_npmJsonOpts":{"file":"/home/tim/.npm/nstore/0.4.0/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"nstore@0.4.0","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.15","_nodeVersion":"v0.4.9","_defaultsLoaded":true,"dist":{"shasum":"488fd5bc28e936e0e75d043efee9f51f75085d1a","tarball":"https://registry.npmjs.org/nstore/-/nstore-0.4.0.tgz","integrity":"sha512-zGS5v4InrW+vp0f5LBRneCNcX15I4nWsKT+NmeE3Ofr3kdpeeGIqda3yl7VihZVxQWvcMM8iAyBOLXMmnCqvMA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBaNuEzM5wJGMokwHdCl675B4Aa+BHxvFjKf9pRv7j8WAiA69ozXgLsMAt5FuSbdbIQ/+jxzlaCVvZOnV4IUwfxt6g=="}]},"scripts":{},"directories":{}},"0.5.0":{"name":"nstore","version":"0.5.0","description":"nStore is a simple, in-process key/value database for node.js.","tags":["nosql","database","pattern"],"author":{"name":"Tim Caswell","email":"tim@creationix.com"},"repository":{"type":"git","url":"git://github.com/creationix/nstore.git"},"bugs":{"name":"http://github.com/creationix/nstore/issues"},"engines":["node >= 0.4.0"],"main":"nstore.js","dependencies":{"step":">=0.0.3","pattern":">=0.2.0"},"_npmJsonOpts":{"file":"/home/tim/.npm/nstore/0.5.0/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"nstore@0.5.0","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.15","_nodeVersion":"v0.4.9","_defaultsLoaded":true,"dist":{"shasum":"006aa0ecfde937adba328402392c12864d848464","tarball":"https://registry.npmjs.org/nstore/-/nstore-0.5.0.tgz","integrity":"sha512-UTzgg+U10tGPWt2C7PRrh4K+RfUIsL0J7OvQlI4/nZYgNardjn1bs3hy/4OA//Eoym0Gk6NJKBHL3vBwz6TwrA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE7dWhjEoOXz6L5HzGHC5Fsqm0+SpJfTFAw9o0oMy4+sAiEAysZMt3TDoQtpPQBD6+WP7Y/YabbFdBwrkp6yRkWDYlU="}]},"scripts":{}},"0.5.1":{"name":"nstore","version":"0.5.1","description":"nStore is a simple, in-process key/value database for node.js.","tags":["nosql","database","pattern"],"author":{"name":"Tim Caswell","email":"tim@creationix.com"},"repository":{"type":"git","url":"git://github.com/creationix/nstore.git"},"bugs":{"name":"http://github.com/creationix/nstore/issues"},"engines":["node >= 0.4.0"],"main":"nstore.js","dependencies":{"step":">=0.0.3","pattern":">=0.2.0"},"_npmJsonOpts":{"file":"/home/tim/.npm/nstore/0.5.1/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"nstore@0.5.1","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.15","_nodeVersion":"v0.4.9","_defaultsLoaded":true,"dist":{"shasum":"500bfce7281e6dc5bfdf98986910c9876727414c","tarball":"https://registry.npmjs.org/nstore/-/nstore-0.5.1.tgz","integrity":"sha512-v/Y3aJLrrZEalEWxaBgp9gytp1/LWPFx3kqRvBagcQsnbq7YgAEHUtXPQ/fWOyEKseTTnp5nqmMn7piBnfUlLA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICjC53GcEcMUjQ4Fnoph5NPvu1/l0a3WizzblYhq1IlxAiBzwMAtKBN6azuYN5uRSZKHPb5UI+61ZZZyOATqknY9cw=="}]},"scripts":{}},"0.5.2":{"name":"nstore","version":"0.5.2","description":"nStore is a simple, in-process key/value database for node.js.","tags":["nosql","database","pattern"],"author":{"name":"Tim Caswell","email":"tim@creationix.com"},"repository":{"type":"git","url":"http://github.com/creationix/nstore.git"},"bugs":"http://github.com/creationix/nstore/issues","engines":["node >= 0.4.0"],"main":"nstore.js","dependencies":{"step":">=0.0.3","pattern":">=0.2.0"},"_id":"nstore@0.5.2","dist":{"shasum":"2028b130a0837d97e0c9cb3f7d42da9a507b8c54","tarball":"https://registry.npmjs.org/nstore/-/nstore-0.5.2.tgz","integrity":"sha512-Aq65n+svq56MUjW5JZaSMN467lAzp0SRUH9zEGbWytLsdeFsCeY+ydNF0KgZLz9Zwsi800s5eAlKmkOsewxVrQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDu8LdfI3GYcq3IyNpRX4xb1bLrmUYVIYyQ+WzT1GiB2AIhAORvvEkd7IWFwNW8iza80ceofTT5kO49VGI7YriqQ3wG"}]},"_from":".","_npmVersion":"1.2.15","_npmUser":{"name":"creationix","email":"tim@creationix.com"},"maintainers":[{"name":"creationix","email":"tim@creationix.com"}]}},"maintainers":[{"name":"creationix","email":"tim@creationix.com"}],"author":{"name":"Tim Caswell","email":"tim@creationix.com"},"repository":{"type":"git","url":"http://github.com/creationix/nstore.git"},"time":{"modified":"2022-06-22T12:00:47.545Z","created":"2011-07-08T21:54:40.435Z","0.3.0":"2011-07-08T21:54:40.435Z","0.4.0":"2011-07-08T21:54:40.435Z","0.5.0":"2011-07-08T22:32:15.454Z","0.5.1":"2011-07-12T21:32:41.480Z","0.5.2":"2013-04-02T13:27:11.869Z"},"users":{"moronicsmurf":true,"parroit":true,"semencov":true,"erincinci":true},"readme":"# nStore\n\nA simple in-process key/value document store for node.js. nStore uses a safe append-only data format for quick inserts, updates, and deletes.  Also a index of all documents and their exact location on the disk is stored in in memory for fast reads of any document.  This append-only file format means that you can do online backups of the datastore using simple tools like rsync.  The file is always in a consistent state.\n\n## Warning\n\nThis library is still under development.  There are bugs.  APIs will change.  Docs may be wrong.\n\nKeep in mind this is something I make in my free time and that's something I've had very little of lately thanks to my many other projects.  I would love for someone with database and javascript smarts to partner with to make nStore super awesome.\n\n## Setup\n\nAll the examples assume this basic setup. Loading the database is async so there is a callback for when it's safe to query the database.\n\nCreating a database is easy, you just call the nStore function to generate a collection object.\n\n    // Load the library\n    var nStore = require('nstore');\n    // Create a store\n    var users = nStore.new('data/users.db', function () {\n      // It's loaded now\n    });\n\n\n## Creating a document\n\nTo insert/update documents, just call the save function on the collection.\n\n    // Insert a new document with key \"creationix\"\n    users.save(\"creationix\", {name: \"Tim Caswell\", age: 29}, function (err) {\n        if (err) { throw err; }\n        // The save is finished and written to disk safely\n    });\n\n    // Or insert with auto key\n    users.save(null, {name: \"Bob\"}, function (err, key) {\n        if (err) { throw err; }\n        // You now have the generated key\n    });\n\n## Loading a document\n\nAssuming the previous code was run, a file will now exist with the persistent data inside it.\n\n    // Load the document with the key \"creationix\"\n    users.get(\"creationix\", function (err, doc, key) {\n        if (err) { throw err; }\n        // You now have the document\n    });\n\n\n## Removing a document\n\nRemove is by key only.\n\n    // Remove our new document\n    users.remove(\"creationix\", function (err) {\n        if (err) { throw err; }\n        // The document at key \"creationix\" was removed\n    });\n\n## Clearing the whole collection\n\nYou can also quickly clear the entire collection\n\n    // Clear\n    users.clear(function (err) {\n      // The database is now empty\n    });\n\nThis clears all the keys and triggers a compaction.  Only after the compact finishes is the data truly deleted from the disk, however any further queries cannot see the old data anymore.\n\n## Querying the database\n\nThere are no indexes, however, nStore provides a simple query interface to get at data quickly and easily.  You can filter using `condition` expressions or plain functions.\n\nTo use queries, you need to include the query addon.\n\n    var nStore = require('nstore');\n    nStore = nStore.extend(require('nstore/query')());\n\n### Query as a single callback\n\nFor convenience you can pass in a callback and get the results as a single object.\n\n    // Using a callback for buffered results\n    users.find({age: 29}, function (err, results) {\n      // results is an object keyed by document key with the document as the value\n    });\n\n\n### Query using streams.\n\nAlso you can stream results.\n\n    var stream = users.find({age: 29});\n    stream.on(\"document\", function (doc, key) {\n      // This is a single document\n    });\n    stream.on(\"end\", function () {\n      // No more data is expected\n    })\n\n### `all` shortcut\n\nIf you want no condition you can use the `all()` shortcut.\n\n    users.all(function (err, results) {\n      // All the users are now in a single object.\n    });\n\n### Structure of `condition` expressions.\n\nA simple condition is pairs of key's and values.  This builds a condition where all columns named by the key must equal the corresponding value.\n\nThis matches rows where `name` is `\"Tim\"` and `age` is `29`:\n\n    {name: \"Tim\", age: 29}\n\nIf a key contains space, then the operator after it is used instead of equal.\n\nThis matches rows where `age` is greater than `18` and `age` is less than `50`:\n\n    {\"age >\": 18, \"age <\": 50}\n\nThe supported operators are:\n\n - `<` - less than\n - `<=` - less than or equal to\n - `>=` - greater than or equal to\n - `>` - greater than\n - `!=` or `<>` - not equal to\n  \nIf an array of hash-objects is passed in, then each array item is grouped and ORed together.\n\nThis matches `name` is `\"Tim\"` or `age` < `8`:\n\n    [{name: \"Tim\"}, {\"age <\": 8}]\n\n\n## Special compaction filter\n\nThere are times that you want to prune stale data from a database, like when using nStore to store session data.  The problem with looping over the index keys and calling `remove()` on them is that it bloats the file. Deletes are actually appends to the file.  Instead nStore exposes a special filter function that, if specified, will filter the data when compacting the data file.\n\n    // Prune any items that have a doc.lastAccess older than 1 hour.\n    var session = nStore.new('data/sessions.db', function () {\n      // It's loaded now\n    });\n    session.filterFn = function (doc, meta) {\n      return doc.lastAccess > Date.now() - 360000;\n    };\n\n","readmeFilename":"README.markdown"}