{"_id":"hive-model","_rev":"34-70d09b8577c68980993657fd768e7f65","name":"hive-model","description":"A local-memory model/database system for storing and retrieving object based data","dist-tags":{"latest":"0.1.2"},"versions":{"0.0.1":{"name":"hive-model","version":"0.0.1","description":"A local-memory model/database system for storing and retrieving object based data","main":"index.js","dependencies":{"hive-component":"*","underscore":"~1.4.3","tap":"*","gate":"*","support":"*"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/bingomanatee/hive-model.git"},"keywords":["model","node","hive"],"author":{"name":"Dave Edelhart"},"license":"BSD","_id":"hive-model@0.0.1","dist":{"shasum":"01f7a9549f67f4bd66dfc62480a59a59f69ab04e","tarball":"https://registry.npmjs.org/hive-model/-/hive-model-0.0.1.tgz","integrity":"sha512-TYxxP6eWw6OMarGS1AArVvb8U38CPiFOZPV/g/nbn0YnWLlQWfgIxgWhiM76UR1xBl4DU6Cyo1sks95zUN/fGQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCIWd/kgQVCTM3doKlBT7Q3c3VWjIS4v5H6w3XNKCPZRQIgWcTzecd0xlOFYdYyUBQVeblEIeZSP/tBPWXOxmxYrEg="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"bingomanatee","email":"dave@wonderlandlabs.com"},"maintainers":[{"name":"bingomanatee","email":"dave@wonderlandlabs.com"}],"directories":{}},"0.1.0":{"name":"hive-model","version":"0.1.0","description":"A local-memory model/database system for storing and retrieving object based data","main":"index.js","dependencies":{"hive-component":"*","underscore":"~1.4.3","tap":"*","gate":"*","support":"*"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/bingomanatee/hive-model.git"},"keywords":["model","node","hive"],"author":{"name":"Dave Edelhart"},"license":"BSD","_id":"hive-model@0.1.0","dist":{"shasum":"fa520fec8511624118b7b2b5ef5411089ea72e9b","tarball":"https://registry.npmjs.org/hive-model/-/hive-model-0.1.0.tgz","integrity":"sha512-tl60owxjAdnnlH04tTSLSeGd+X6M9Ho91v6i9gZxNmzQ3Z3RNv0clURIzsVoMpdWOlwLTAbxdQaO6T3E7OPvlQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCVmdxB9aUF6bfqT8zQGRaIxe4pENdu0ORft2gFrsbfXgIhAJ65tfJt06dEu9+RNdlOkH+hgcXLN0h3EgyKzlugel4t"}]},"_npmVersion":"1.1.62","_npmUser":{"name":"bingomanatee","email":"dave@wonderlandlabs.com"},"maintainers":[{"name":"bingomanatee","email":"dave@wonderlandlabs.com"}],"directories":{}},"0.0.1-a":{"name":"hive-model","version":"0.0.1-a","description":"A local-memory model/database system for storing and retrieving object based data","main":"index.js","dependencies":{"hive-component":"*","underscore":"~1.4.3","tap":"*","gate":"*","support":"*"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/bingomanatee/hive-model.git"},"keywords":["model","node","hive"],"author":{"name":"Dave Edelhart"},"license":"BSD","_id":"hive-model@0.0.1-a","dist":{"shasum":"6cf41a063596e051fd687121167a328efffde12e","tarball":"https://registry.npmjs.org/hive-model/-/hive-model-0.0.1a.tgz","integrity":"sha512-cNb1NXjmDHMhZUvJ02IpI1eh//AS1oXvQlknv29vtwDMOxlpPflZa6GgX1lMz3Rgn1+06lBAWZ7nvrs227jf0Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIArpjrVtKS32z5vdX+tRF30i+o+Mx3OH3JAl9muPYuErAiAH+KHvQclaBYgQpRYvqfE4tkx7A3b+RmvOcjuzTrawJw=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"bingomanatee","email":"dave@wonderlandlabs.com"},"maintainers":[{"name":"bingomanatee","email":"dave@wonderlandlabs.com"}],"directories":{}},"0.0.1-b":{"name":"hive-model","version":"0.0.1-b","description":"A local-memory model/database system for storing and retrieving object based data","main":"index.js","dependencies":{"hive-component":"*","underscore":"~1.4.3","tap":"*","gate":"*","support":"*"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/bingomanatee/hive-model.git"},"keywords":["model","node","hive"],"author":{"name":"Dave Edelhart"},"license":"BSD","_id":"hive-model@0.0.1-b","dist":{"shasum":"878cb72a13bc7bbcf286872506b42d3226be4515","tarball":"https://registry.npmjs.org/hive-model/-/hive-model-0.0.1b.tgz","integrity":"sha512-WqSZPXVlbJ83bh33tmDY2pxPFx0/swYic/hEgaE2iJraQyyFTJYf3SMHCsfh4XdnaSaT86k31rwaZdJl29qMNw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDFeu6Lt5lMLSV5bgM6R+UsCEmHCjNdb/xmzniN15LbwwIgCUV9fVnbUfl5yimraSjxjF9ObGek64H9HGVkn9Sw9Ac="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"bingomanatee","email":"dave@wonderlandlabs.com"},"maintainers":[{"name":"bingomanatee","email":"dave@wonderlandlabs.com"}],"directories":{}},"0.0.1-c":{"name":"hive-model","version":"0.0.1-c","description":"A local-memory model/database system for storing and retrieving object based data","main":"index.js","dependencies":{"hive-component":"*","underscore":"~1.4.3","tap":"*","gate":"*","support":"*"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/bingomanatee/hive-model.git"},"keywords":["model","node","hive"],"author":{"name":"Dave Edelhart"},"license":"BSD","_id":"hive-model@0.0.1-c","dist":{"shasum":"0127ad775665f9c3d2dc3d49a591515482b3c5ce","tarball":"https://registry.npmjs.org/hive-model/-/hive-model-0.0.1c.tgz","integrity":"sha512-wEP8516ic/ay8XRgIaQ96rH5YJwuRgQDdjwudcYkP6OU9PD9VwcOIU+H/pUgfsxM0owtxzzSpGHItBFT2tulgg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFlYVQp0CT3SuXzmKIIuggme0gHorawEjrlesrPre4BLAiBBjDt+vyOd69g999/pk+8HX326d41kyk2A6Z1b11VIcg=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"bingomanatee","email":"dave@wonderlandlabs.com"},"maintainers":[{"name":"bingomanatee","email":"dave@wonderlandlabs.com"}],"directories":{}},"0.0.1-d":{"name":"hive-model","version":"0.0.1-d","description":"A local-memory model/database system for storing and retrieving object based data","main":"index.js","dependencies":{"hive-component":"*","underscore":"~1.4.3","tap":"*","gate":"*","support":"*"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/bingomanatee/hive-model.git"},"keywords":["model","node","hive"],"author":{"name":"Dave Edelhart"},"license":"BSD","_id":"hive-model@0.0.1-d","dist":{"shasum":"6ebe932d3103b7e7d5672e55bb8bcc03dd22e1dd","tarball":"https://registry.npmjs.org/hive-model/-/hive-model-0.0.1d.tgz","integrity":"sha512-O55kUQALay8GzhrKsMfeKzD2JIdOE1bF2XJcgcE7TmOrEu4hmjhzDJd2maENK9EuJBdHCJIOoLsJzKi0F8GQcQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICvuALnHsTXjXK0sJHL2OCGYkVt7URqhJoAXqw3xqXrQAiARUTFALM4ylwAfXyxFqzd9nFjq2G+97Q1rW1F5IN3Xkw=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"bingomanatee","email":"dave@wonderlandlabs.com"},"maintainers":[{"name":"bingomanatee","email":"dave@wonderlandlabs.com"}],"directories":{}},"0.0.1-e":{"name":"hive-model","version":"0.0.1-e","description":"A local-memory model/database system for storing and retrieving object based data","main":"index.js","dependencies":{"hive-component":"*","underscore":"~1.4.3","tap":"*","gate":"*","support":"*"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/bingomanatee/hive-model.git"},"keywords":["model","node","hive"],"author":{"name":"Dave Edelhart"},"license":"BSD","_id":"hive-model@0.0.1-e","dist":{"shasum":"f5a1b732ae00a15b33702489c04c25b942335f35","tarball":"https://registry.npmjs.org/hive-model/-/hive-model-0.0.1e.tgz","integrity":"sha512-1KXSwhdPN0pRRHNTqA1WvAmHVqTfXN9MezB+n0H+24NXnII501GdWQvFvYARnqSEl/BgRkkm7TE++4EEIYwgIA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCXbk87CqXca/TaRYebAsikGysPXPeBN1iy/jcFZUWKhgIgUYuNZOTNUMbxFi93TNAoCkpoh9aoH2hT1oP10yCd+Y4="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"bingomanatee","email":"dave@wonderlandlabs.com"},"maintainers":[{"name":"bingomanatee","email":"dave@wonderlandlabs.com"}],"directories":{}},"0.0.1-f":{"name":"hive-model","version":"0.0.1-f","description":"A local-memory model/database system for storing and retrieving object based data","main":"index.js","dependencies":{"hive-component":"*","underscore":"~1.4.3","tap":"*","gate":"*","support":"*"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/bingomanatee/hive-model.git"},"keywords":["model","node","hive"],"author":{"name":"Dave Edelhart"},"license":"BSD","_id":"hive-model@0.0.1-f","dist":{"shasum":"850e2f9559a4d1d6654fdeccb3aee6be333d6118","tarball":"https://registry.npmjs.org/hive-model/-/hive-model-0.0.1f.tgz","integrity":"sha512-16miGtaMskTqedg8B7UdOK02llvqV7ztPogZnPuGwJ3sZdsP3+MyQtiRzOsGZM3NPdNGTA1JKgnxF5fEG4/MSA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFA09Ur5CXji7yyR/D01qsKwEXLQKK4jK3cPw+6jw/mwAiA33qGtEpC+8uuatYKMwAdaEOXD1oPt1ZNlv765p/ItaQ=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"bingomanatee","email":"dave@wonderlandlabs.com"},"maintainers":[{"name":"bingomanatee","email":"dave@wonderlandlabs.com"}],"directories":{}},"0.1.2":{"name":"hive-model","version":"0.1.2","description":"A local-memory model/database system for storing and retrieving object based data","main":"index.js","dependencies":{"hive-component":"*","underscore":"~1.4.3","tap":"*","gate":"*","support":"*"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/bingomanatee/hive-model.git"},"keywords":["model","node","hive"],"author":{"name":"Dave Edelhart"},"license":"BSD","bugs":{"url":"https://github.com/bingomanatee/hive-model/issues"},"homepage":"https://github.com/bingomanatee/hive-model","_id":"hive-model@0.1.2","_from":".","dist":{"shasum":"2e8e1302d22ac837a0b5d3d2b646b7d48287620f","tarball":"https://registry.npmjs.org/hive-model/-/hive-model-0.1.2.tgz","integrity":"sha512-99Hd/0W3gFSzUTkOEMgumD49GcgEcD6cBGYNr7BXfmiXpYb15BPIe/4UNZmN7cA//ODdP5HT5GzEQLAO5CQm+w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCD5h2I3E/O6TrmHLJZiq0msHMKOWK6PJZWWPJm+sbsLwIhAIkK48HxQxUQeGtoKwVuA0F23Sj5limsAwQcf3P6F8v3"}]},"_npmVersion":"1.3.14","_npmUser":{"name":"bingomanatee","email":"dave@wonderlandlabs.com"},"maintainers":[{"name":"bingomanatee","email":"dave@wonderlandlabs.com"}]}},"readme":"hive-model\n==========\n\nA javascript based database for local memory based storage of data or resources.\n\nModels are lists of data a la backbone collections.\nThey can contain any sort of data.\n\n\nModels are not designed for any specific backend. They are designed to\nprovide real-time node repositories of records for transient information management.\n\nThere is no structural schema for model data or structure, beyond the existence\nof a unique identifying key identified by the _pk property (that defaults to 'id').\nAlthough the default _make_pk assumes integer based IDs, you can easily override this\nfor a different index basis.\n\nDataspaces\n----------\n\nModels are stored in dataspaces, which ensure/maintain uniqueness of model name within the dataspace.\nDataspaces are hive-components that store models by name in their config.\n\nQueries\n-------\n\nMany methods of the model have optional callbacks that if omitted result in a query object being returned.\nQuery objects allow you to compound filtering operations such as\n\n<code>\n\tvar hive_model = require('hive-model');\n\n\tvar ds = hive_model.Dataspace();\n\n\tvar myModel = hive_model.Model({data: [\n\t\t\t{id: 1, name: 'alpha', weight: 200},\n\t\t\t{id: 2, name: 'beta', weight: 100},\n\t\t\t{id: 3, name: 'delta', weight: 0},\n\t\t\t{id: 4, name: 'gamma': weight: 100},\n\t\t]\n\t}, {name: 'foos'}, ds);\n\n\tvar lightweights = myModel.find(function(record){ return record.weight <= 100; });\n\n\t// note - lightweights is not an array of objects: it is a query object.\n\t// There is no guarantee of ordering of the records returned .. yet.\n\n\tvar lightweight_records = lightweights.records();\n\n\t// these are the records from the query object.\n\n\tvar sorted_lightweights = lightweights.sort('name');\n\n\t// sorted_lightweights is another query;\n\n\tvar sorted_lightweight_records = sorted_lightweights.records();\n\n\t// HERE we have the desired result - all foos that weight up to 100, ordered by name.\n\n\t// the practical way to use queries is to chain commands and end with a records output.\n\n\tvar slr_faster = myModel.find(function(record){ return record.weight <= 100;}).sort('name').records()\n\n</code>\n\nCreating a Model\n----------------\n\nModels are instances of the hive-component Component system.\nA hive-component Component is created with the following API:\n\n<code>\n\tvar hive_component = require('hive-component');\n\n\tvar mixins = {\n\t\tincrement: function(){\n\t\t\tvar c = this.get_config('value') + 1;\n\t\t\tthis.set_config(c);\n\t\t\treturn c;\n\t\t}\n\t}\n\n\tvar config = {\n\t\tvalue: 0;\n\t}\n\n\t// you can think of the API as \"hive_component({methods}, {properties})\" -- usually -- but once in a while\n\t// you will need to pass data in as a mixin, as is the case with model data.\n\tvar MyCompFactory = hive_component(mixins, config);\n\n\tvar mycomp = MyComp():\n\n\tmycomp.get_config('value') // 0;\n\tmycomp.increment();\n\tmycomp.get_config('value') // 1;\n</code>\n\nThe Model function allows for a third argument, to pass the dataspace in seperately, as shown aboe.\nYou can also create a service that buries the dataspace in closure as in:\n\n<code>\n\tvar hive_model = require('hive-model');\n\n\tvar ds = hive_model.Dataspace();\n\n\tvar ds_factory = Model.factory(ds);\n\n\nvar _model_bar_mixin = {\n\tname: 'bar_model',\n\tdata: [\n\t\t{id: 1, name: 'a', weight: 100}\n\t\t,\n\t\t{id: 2, name: 'b', weight: 150}\n\t\t,\n\t\t{id: 3, name: 'c', weight: 200}\n\t\t,\n\t\t{id: 4, name: 'aa', weight: 125}\n\t\t,\n\t\t{id: 5, name: 'ab', weight: 175}\n\t\t,\n\t\t{id: 6, name: 'ba', weight: 50}\n\t\t,\n\t\t{id: 7, name: 'bb', weight: 75}\n\t\t]\n\t}\n\n\tvar bar_model = ds_factory(_model_bar_mixin, {_pk: 'id'});\n</code>\n\nTHE NAME IS REQUIRED in the first parameter. Its how dataspace indeses the model. You don't have to pass data\nin, though if you have it its a convenient way to start up your model.\n\nThe second parameter (config) has no mandataory properties, unless you want to use an object whose _pk (primary key)\nis different than \"id\".\n\nAdding Data\n-----------\n\nYou can add data to a model in one of three ways:\n\n1) initally, as in the example above.\n2) record by record via my_model.put({foo: 1, bar: 2});\n3) in an array of data viar my_model.add([{}, {}]);\n\nEach of these actions will emit('record', record) for each individual record. If you want to hook your data to a real\n repo, you can do so by listening for this event.\n\n Updating Data\n -------------\n\n Putting data in that already has a PK value will overwrite / update a record; you can also call update\n to update a single record based on its ID, or by calling my_model.update(filter_function,\n\n","maintainers":[{"name":"bingomanatee","email":"dave@wonderlandlabs.com"}],"time":{"modified":"2022-06-18T20:52:49.930Z","created":"2013-01-02T20:02:19.952Z","0.0.1":"2013-01-02T20:02:20.905Z","0.0.1a":"2013-01-30T19:31:11.999Z","0.0.1b":"2013-01-31T21:46:15.532Z","0.0.1c":"2013-03-22T21:40:44.880Z","0.0.1d":"2013-03-22T22:24:28.220Z","0.0.1e":"2013-03-22T23:08:12.970Z","0.0.1f":"2013-05-31T18:26:09.864Z","0.1.0":"2013-07-19T17:12:01.771Z","0.1.1":"2014-01-27T17:14:32.666Z","0.0.1-a":"2014-01-27T17:55:10.310Z","0.0.1-b":"2014-01-27T17:55:10.310Z","0.0.1-c":"2014-01-27T17:55:10.310Z","0.0.1-d":"2014-01-27T17:55:10.310Z","0.0.1-e":"2014-01-27T17:55:10.310Z","0.0.1-f":"2014-01-27T17:55:10.310Z","0.1.2":"2014-01-27T17:56:39.618Z"},"author":{"name":"Dave Edelhart"},"repository":{"type":"git","url":"git://github.com/bingomanatee/hive-model.git"},"readmeFilename":"README.md"}