{"_id":"tiny","_rev":"17-3bc912b3730b8360780b7e1d135f135c","name":"tiny","description":"An in-process key-value store","dist-tags":{"latest":"0.0.10"},"versions":{"0.0.4":{"name":"tiny","description":"an in-process database","author":{"name":"Christopher Jeffrey"},"version":"0.0.4","main":"./lib/tiny.js","bin":{"tiny":"./bin/tiny"},"repository":{"type":"git","url":"git://github.com/chjj/node-tiny.git"},"keywords":["database","nosql","in-process"],"dependencies":{},"devDependencies":{},"_id":"tiny@0.0.4","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.3","_nodeVersion":"v0.4.7","_defaultsLoaded":true,"dist":{"shasum":"58ee0feecf751634b512994c7a931eaf9664ce5e","tarball":"https://registry.npmjs.org/tiny/-/tiny-0.0.4.tgz","integrity":"sha512-OwD3AiUboqlbUmv1+WuaeWk7EPUzA5U0N3Ief0t5NGJl0B3BlYvHAnJZRTuHWl4eWEd50C67wJs7f0ajpydlrA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH+cKoVuQBmyxSECcsQLkv3EjtaaLT0Q5G/stjWnHTXCAiBbX95yTvWoINUOUVSRcHc2DwW2gAQvJToXiozH+O7dgg=="}]},"scripts":{},"_npmUser":{"name":"chjj","email":"chjjeffrey@gmail.com"},"maintainers":[{"name":"chjj","email":"chjjeffrey@gmail.com"}]},"0.0.5":{"name":"tiny","description":"an in-process database","author":{"name":"Christopher Jeffrey"},"version":"0.0.5","main":"./lib/tiny.js","bin":{"tiny":"./bin/tiny"},"repository":{"type":"git","url":"git://github.com/chjj/node-tiny.git"},"keywords":["database","nosql","in-process"],"_npmJsonOpts":{"file":"/home/cjj/.npm/tiny/0.0.5/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"tiny@0.0.5","dependencies":{},"devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.22","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"b1af0c0fd8e431067e041c93a68a7c82bc67ea0b","tarball":"https://registry.npmjs.org/tiny/-/tiny-0.0.5.tgz","integrity":"sha512-mZ+J03vv8O/xvv95gHnaPvE/xSDQL4jk3QWuyLKNqWaJDfDx/l+n2GlkD7ORqxqjc+0eaHdtspa5O6JJmDMKVw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCHqLeHaRVPT3Cr6pGmfX3uyy5e5YIwp+Z7aHOXBlzClAIhAM7GhvUSF6nhupc9whnCiMh6pL/Qyw6WUdq0l3vSEQvH"}]},"scripts":{},"maintainers":[{"name":"chjj","email":"chjjeffrey@gmail.com"}],"_npmUser":{"name":"chjj","email":"chjjeffrey@gmail.com"}},"0.0.6":{"name":"tiny","description":"an in-process database","author":{"name":"Christopher Jeffrey"},"version":"0.0.6","main":"./lib/tiny.js","bin":{"tiny":"./bin/tiny"},"repository":{"type":"git","url":"git://github.com/chjj/node-tiny.git"},"keywords":["database","nosql","in-process"],"_npmJsonOpts":{"file":"/home/cjj/.npm/tiny/0.0.6/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"tiny@0.0.6","dependencies":{},"devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.22","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"64c72ffb92e4d135a223e9159975ab9b31bcec4d","tarball":"https://registry.npmjs.org/tiny/-/tiny-0.0.6.tgz","integrity":"sha512-pouFa4cNPLwjd6Wl1+3lBc0JTfPH2D/ppm1Fdc2RHqU5HKQ/Rv479Q7XyCzVl7iJgmWCupTWlDGXiNI0Q05Z9Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCDUMaG8qgJrIN4ZWD9qFbX8wGUAMN/lMgTcfv1aPyKMQIgUaUAUKcyc4nyPnpr3CbMMvkg9OrKW1y036zYYv6TCpg="}]},"scripts":{},"maintainers":[{"name":"chjj","email":"chjjeffrey@gmail.com"}],"_npmUser":{"name":"chjj","email":"chjjeffrey@gmail.com"}},"0.0.7":{"name":"tiny","description":"an in-process database","author":{"name":"Christopher Jeffrey"},"version":"0.0.7","main":"./lib/tiny.js","bin":{"tiny":"./bin/tiny"},"repository":{"type":"git","url":"git://github.com/chjj/node-tiny.git"},"keywords":["database","nosql","in-process"],"_npmJsonOpts":{"file":"/home/cjj/.npm/tiny/0.0.7/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"tiny@0.0.7","dependencies":{},"devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.22","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"f3a43b2f3e277fdb0a7f37a97a8be67efd88cbbd","tarball":"https://registry.npmjs.org/tiny/-/tiny-0.0.7.tgz","integrity":"sha512-XK32/4UhwbDLnZVNUmq2f+aH+uSbF9Ero2vhc7RHR2T+7ei8L+bSR5EKGxHVDOh9auaoHdZhnGVZ80ffT98pAw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBwmbsG3ZlYaCeANsp/uw6JTc4CWlbhoiRjoXMiVEZzXAiA8KcShWVZTakPbPovc69dA4UmG8PR2FIcBUyAkyJPxpg=="}]},"scripts":{},"maintainers":[{"name":"chjj","email":"chjjeffrey@gmail.com"}],"_npmUser":{"name":"chjj","email":"chjjeffrey@gmail.com"}},"0.0.8":{"name":"tiny","description":"an in-process database","author":{"name":"Christopher Jeffrey"},"version":"0.0.8","main":"./lib/tiny.js","bin":{"tiny":"./bin/tiny"},"repository":{"type":"git","url":"git://github.com/chjj/node-tiny.git"},"keywords":["database","nosql","in-process"],"_npmUser":{"name":"chjj","email":"chjjeffrey@gmail.com"},"_id":"tiny@0.0.8","dependencies":{},"devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.0-alpha-2","_nodeVersion":"v0.6.3","_defaultsLoaded":true,"dist":{"shasum":"5944bfbee8e7b048e89392614394ca61a3affd1c","tarball":"https://registry.npmjs.org/tiny/-/tiny-0.0.8.tgz","integrity":"sha512-dIt/kZTJfvbuqU8HI6C6bMw0J7YcjlwKmcVT3m5M93ooIasBzzlDjqaOoNiFa2CejuIWGrADFkF1+ro1Ho2IJA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGuYIwqvC72Wy2C2CM5v60Xvbl7hbtIshAlFMXa3GRpZAiBFuwuVAG/7oOPBelipNZcKYJ6yxodaEyz2yzteYeykuw=="}]},"maintainers":[{"name":"chjj","email":"chjjeffrey@gmail.com"}]},"0.0.9":{"name":"tiny","description":"An in-process key-value store","author":{"name":"Christopher Jeffrey"},"version":"0.0.9","main":"./lib/tiny.js","bin":{"tiny":"./bin/tiny"},"man":["./man/tiny.1"],"preferGlobal":true,"repository":{"type":"git","url":"git://github.com/chjj/tiny.git"},"homepage":"https://github.com/chjj/tiny","bugs":{"url":"http://github.com/chjj/tiny/issues"},"license":"MIT","keywords":["database","nosql","in-process"],"tags":["database","nosql","in-process"],"scripts":{"test":"node test","bench":"node test --bench"},"_id":"tiny@0.0.9","_shasum":"29df6d6f3bf567ce3e33d8728612b90155e47b15","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"chjj","email":"chjjeffrey@gmail.com"},"maintainers":[{"name":"chjj","email":"chjjeffrey@gmail.com"}],"dist":{"shasum":"29df6d6f3bf567ce3e33d8728612b90155e47b15","tarball":"https://registry.npmjs.org/tiny/-/tiny-0.0.9.tgz","integrity":"sha512-mEkX6/mkA6kube/DMxEO62jaZwJeHTeLFqhhuYcqdYxjfLYZ8yFCdFgqWtjzsoYA5zsUv//7/LzIeM8plT2YzA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGCiQcI8w+DqizcGbvXVpbfbbLbDLatmMha/jJWCkDPkAiEAkPK0j963Y9kM6PyfKiDwDVARwzj4wxv0HtsebgxviMg="}]}},"0.0.10":{"name":"tiny","description":"An in-process key-value store","author":{"name":"Christopher Jeffrey"},"version":"0.0.10","main":"./lib/tiny.js","bin":{"tiny":"./bin/tiny"},"man":["./man/tiny.1"],"preferGlobal":true,"repository":{"type":"git","url":"git://github.com/chjj/tiny.git"},"homepage":"https://github.com/chjj/tiny","bugs":{"url":"http://github.com/chjj/tiny/issues"},"license":"MIT","keywords":["database","nosql","in-process"],"tags":["database","nosql","in-process"],"scripts":{"test":"node test","bench":"node test --bench"},"dependencies":{"lru-cache":"~2.5.0"},"engines":{"node":">= 0.8.0"},"_id":"tiny@0.0.10","_shasum":"92d540b507c67034b8c7a53797aeb30b6c1780a3","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"chjj","email":"chjjeffrey@gmail.com"},"maintainers":[{"name":"chjj","email":"chjjeffrey@gmail.com"}],"dist":{"shasum":"92d540b507c67034b8c7a53797aeb30b6c1780a3","tarball":"https://registry.npmjs.org/tiny/-/tiny-0.0.10.tgz","integrity":"sha512-BbTnGYnHGMf6/ctSctXyIGFQ3afpio2Xw2mlPONTL1pqeggpBAC80bZaoAJdsIqBFA8Ccp5ltJoz0YDWaxF3pg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF96UfZ8lMMS+TARVo61EX5EB//t8EsePI0YgCHnsquyAiEA6XUDDhoyYKzX7K+1cb3eXFD8j6TbWNupVnRyy0a2xVM="}]}}},"maintainers":[{"name":"chjj","email":"chjjeffrey@gmail.com"}],"time":{"modified":"2022-06-27T06:57:14.938Z","created":"2011-07-20T06:42:43.303Z","0.0.4":"2011-12-08T18:15:35.613Z","0.0.5":"2011-12-08T18:15:35.613Z","0.0.6":"2011-12-08T18:15:35.613Z","0.0.7":"2011-12-08T18:15:35.613Z","0.0.8":"2011-12-08T18:15:35.613Z","0.0.9":"2014-05-19T01:11:09.573Z","0.0.10":"2014-06-01T00:32:24.082Z"},"author":{"name":"Christopher Jeffrey"},"repository":{"type":"git","url":"git://github.com/chjj/tiny.git"},"readme":"# tiny\n\n__tiny__ is an in-process document/object store for node.js.\n\nIt is largely inspired by [nStore](https://github.com/creationix/nstore),\nhowever, its goal was to implement real querying which goes easy on the memory.\n\nTiny is very simple, there are no schemas, just store your objects. It supports\nmongo-style querying, or alternatively a \"mapreduce-like\" interface similar to\nCouchDB's views.\n\n## Install\n\n``` bash\n$ npm install tiny\n```\n\n## How Tiny works...\n\nTiny takes advantage of the fact that, normally, when you query for records in\na database, you're only comparing small properties (<128b) in the query itself.\nFor example, when you query for articles on a weblog, you'll usually only be\ncomparing the timestamp of the article, the title, the author, the category,\nthe tags, etc. - pretty much everything except the content of the article\nitself.\n\nTiny stores each document/object's property individually in the DB file and\ncaches all the small properties into memory when the DB loads, leaving anything\nabove 128b behind. When a query is performed, Tiny only lets you compare the\nproperties stored in memory, which is what you were going to do anyway. Once\nthe query is complete, Tiny will perform lookups on the FD to grab the large\nproperties and put them in their respective objects before results are returned\nto you.\n\nThis my attempt at combining what I think the best aspects of nStore and\nnode-dirty are. node-dirty is incredibly fast and simple (everything is\nin-memory), and nStore is very memory effecient, (but this only lasts until you\nperform a query). node-tiny allows for queries that perform lookups on the db\nfile, and it selectively caches properties as well, so it's fast and easier on\nmemory.\n\n## Example Querying\n\n``` js\nvar Tiny = require('./tiny');\nTiny('articles.tiny', function(err, db) {\n  var time = Date.now()\n    , low = time - (60*60*1000)\n    , high = time - (30*60*1000);\n\n  // mongo-style query\n  db.find({$or: [\n    { timestamp: { $lte: low } },\n    { timestamp: { $gte: high } }\n  ]})\n  .desc('timestamp')\n  .limit(3)(function(err, results) {\n    console.log('Results:', results);\n  });\n\n  // is equivalent to...\n  db.fetch({\n    desc: 'timestamp',\n    limit: 3\n  }, function(doc, key) {\n    if (doc.timestamp <= low\n        || doc.timestamp >= high) {\n      console.log('Found:', key);\n      return true;\n    }\n  }, function(err, results) {\n    console.log('Results:', results);\n  });\n});\n```\n\nThe mongo-style querying should be fairly self-explanatory. The second query is\nsupposed to be similar to a mapreduce interface, but it's the rough equivalent\nof a `.filter` function.\n\nNote: there is a `shallow` parameter for `.fetch`, `.find`, and `.get`, wherein\nit will __only__ lookup properties that are under 128b in size. This is to go\neasy on the memory. `.each` and `.all` are shallow by default, but they do have\na `deep` parameter, (which I don't recommend using).\n\n## Other Usage\n\n``` js\n// save a document\ndb.set('myDocument', {\n  title: 'a document',\n  content: 'hello world'\n}, function(err) {\n  console.log('set!');\n});\n\n// .each will iterate through\n// every object in the database\n// it is shallow by default\ndb.each(function(doc) {\n  console.log(doc.title);\n});\n\n// returns every object in the DB\n// in an array, this is shallow\n// by default\ndb.all(function(err, docs) {\n  console.log(docs.length);\n});\n\n// remove a doc\ndb.remove('myDocument', function(err) {\n  console.log('deleted');\n});\n\n// retrieve an object from the database\ndb.get('someOtherThing', function(err, data) {\n  // data._key is a property which\n  // holds the key of every object\n  console.log('found:', data._key);\n});\n\n// updates the object\n// without overwriting its other properties\ndb.update('article_1', {\n  title: 'new title'\n}, function(err) {\n  console.log('done');\n});\n\n// close the file descriptor\ndb.close(function(err) {\n  console.log('db closed');\n});\n\n// clean up the mess\ndb.compact(function(err) {\n  console.log('done');\n});\n\n// dump the entire database to a JSON file\n// in the same directory as the DB file\n// (with an optional pretty-print parameter)\ndb.dump(true, function(err) {\n  console.log('dump complete');\n});\n```\n\n## Making data more memory efficient\n\nBecause of the way Tiny works, there are ways to alter your data to make it\nmore memory efficient. For example, if you have several properties on your\nobjects that aren't necessary to for queries, its best to nest them in an\nobject.\n\n``` js\nuser: {\n  name: 'joe',\n  prop1: 'data',\n  prop2: 'data',\n  prop3: 'data'\n}\n\nuser: {\n  name: 'joe',\n  data: {\n    prop1: 'data',\n    prop2: 'data',\n    prop3: 'data'\n  }\n}\n```\n\nThat way, the data will not be cached if it exceeds 128b collectively.\nEventually there may be an `ignore` method or an `index` method, which will be\nexplicitly inclusive or exclusive to which properties are cached and which\nproperties are able to be referenced within a query.\n\n## Documentation\n\n### Database\n- [Construction](#construction)\n- [dump](#dump)\n- [close](#close)\n- [kill](#kill)\n\n### Querying\n- [set](#set)\n- [each](#each)\n- [all](#all)\n\n## Database\n\n<a name=\"construction\"></a>\n\n### Tiny(name, callback)\nCreates and returns a database with the given name.\n\n__Arguments__\n\n- name - filename to store and load the Tiny database\n- callback(err, db) - Called after the database file is opened and loaded\n\n__Example__\n\n``` js\nvar db;\nTiny('./articles.tiny', function(err, db_) {\n  if (err) throw err;\n  db = db_;\n  ...\n});\n```\n\n---------------------------------------\n\n<a name=\"dump\"></a>\n\n### dump(pretty, func) or dump(func)\n\nDumps the a database to a JSON file with the name as name.json. Pretty\nspecifies whether to indent each line with two spaces or not. Alternatively,\ndump(func) can be called.\n\n__Arguments__\n\n- pretty - if true, the JSON file will be indented with two spaces\n- func(err) - called after the dump is complete.\n\n__Example__\n\n``` js\ndb.dump(true, function(err) {\n  console.log('dump complete');\n});\n```\n\n---------------------------------------\n\n<a name=\"close\"></a>\n\n### close(func)\n\nCloses the Tiny database file handle. A new Tiny object must be made to reopen\nthe file.\n\n__Arguments__\n\n- func() - callback function after the database has been closed\n\n__Example__\n\n``` js\ndb.close(function(err) {\n  console.log('db closed');\n});\n```\n\n---------------------------------------\n\n<a name=\"kill\"></a>\n\n### kill(func)\n\nCloses the Tiny database file, deletes the file and all the data in the\ndatabase, and then creates a new database with the same name and file.\n\n__Arguments__\n\n- func() - callback function after the database has been reloaded\n\n__Example__\n\n``` js\ndb.kill(function(err) {\n  console.log('db has been destroyed and a new db has been loaded');\n});\n```\n\n## Querying\n\n<a name=\"set\"></a>\n\n### set(docKey, doc, func)\n\nSaves a object `doc` to database under the key `docKey`. Ideally, docKey should\nbe 128b or smaller.\n\n__Arguments__\n\n- docKey - a key to search the database for\n- doc - an object to save to the database under the given key\n- func - callback function after the doc object has been saved to the database\n\n__Example__\n\n``` js\ndb.set('myDocument', {\n  title: 'a document',\n  content: 'hello world'\n}, function(err) {\n  console.log('set!');\n});\n```\n\n---------------------------------------\n\n<a name=\"each\"></a>\n\n### each(func, deep) or each(func)\n\nIterates through every object in the database.\n\n__Arguments__\n\n- func(doc) - Callback function that is called with every iterated object `doc`\n  from the database\n- done() - Callback to be executed after the iterations complete.\n- deep - `true` if every object should be returned, `false` or unset if only\n  cacheable objects should be returned (ones smaller than 128b)\n\n__Example__\n\n``` js\ndb.each(function(doc) {\n  console.log(doc.title);\n}, function() {\n  console.log('done');\n});\n```\n\n### Contribution and License Agreement\n\nIf you contribute code to this project, you are implicitly allowing your code\nto be distributed under the MIT license. You are also implicitly verifying that\nall code is your original work. `</legalese>`\n\n## License\n\nCopyright (c) 2011-2014, Christopher Jeffrey. (MIT License)\n\nSee LICENSE for more info.\n","homepage":"https://github.com/chjj/tiny","keywords":["database","nosql","in-process"],"bugs":{"url":"http://github.com/chjj/tiny/issues"},"license":"MIT","readmeFilename":"README.md"}