{"_id":"SenseOrm","_rev":"27-9850943d11e7d788efcc4dd1f9e938cd","name":"SenseOrm","description":"ORM for every database: mongodb, mysql, redis","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.2":{"author":{"name":"Alex Ferreira"},"name":"SenseOrm","version":"0.0.2","description":"ORM for every database: mongodb, mysql, redis","keywords":["orm","mongodb","mysql","redis"],"main":"index.js","engines":{"node":">= v0.4.0"},"dependencies":{"mongoose":">= 2.3.10","redis":">= 0.6.7","mysql":">= 0.9.4","riak-js":">= 0.4.1"},"devDependencies":{"nodeunit":"~0.6.2"},"scripts":{"test":"./run-tests.js"},"_npmUser":{"name":"alexferreira","email":"alex@dsol.com.br"},"_id":"SenseOrm@0.0.2","_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.6.0","_defaultsLoaded":true,"dist":{"shasum":"1aa668b216888f77b98217bae80083df4b398f36","tarball":"https://registry.npmjs.org/SenseOrm/-/SenseOrm-0.0.2.tgz","integrity":"sha512-J3/YzxnyjbJy3hHTa/xnzuAhxj/94EZ+Bu1UporKQGiYaML+Xm2MctIVzi6Dq+EqfiQzGVQQpo9Lr4++cQ0ELQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHebU28att2TZj+KU+ooGudVQOjp3c+L+NhoNvlc5sZAAiAvarQjwGkmC9b8INW+LmSYYerfVg2nIV/GYI9kSMfM+g=="}]},"maintainers":[{"name":"alexferreira","email":"alex@dsol.com.br"}],"directories":{}},"0.0.3":{"author":{"name":"Alex Ferreira"},"name":"SenseOrm","version":"0.0.3","description":"ORM for every database: mongodb, mysql, redis","keywords":["orm","mongodb","mysql","redis"],"main":"index.js","engines":{"node":">= v0.4.0"},"dependencies":{"mongoose":">= 2.3.10","redis":">= 0.6.7","mysql":">= 0.9.4","riak-js":">= 0.4.1"},"devDependencies":{"nodeunit":"~0.6.2"},"scripts":{"test":"./run-tests.js"},"_npmUser":{"name":"alexferreira","email":"alex@dsol.com.br"},"_id":"SenseOrm@0.0.3","_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.6.0","_defaultsLoaded":true,"dist":{"shasum":"94c44536a4c8233c4bfaf8d05bde190a74f05da6","tarball":"https://registry.npmjs.org/SenseOrm/-/SenseOrm-0.0.3.tgz","integrity":"sha512-jo/Gupa8tWjXGdq8YakN5CjCgA8VZx3Uji8CImz85lvmnGwFo4yLNinwlcS0czHr4NbAeRgv4bhav3FGTN36fQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICAgdvrDfSyPCU5sK6t07B7z3NljmzGFakb0HTGVxho4AiANG9LdVs3GZ/B/2+9WLQ1mKtAtD2g3MGZ+3mFgkzBqGg=="}]},"maintainers":[{"name":"alexferreira","email":"alex@dsol.com.br"}],"directories":{}},"0.0.4":{"author":{"name":"Alex Ferreira"},"name":"SenseOrm","version":"0.0.4","description":"ORM for every database: mongodb, mysql, redis","keywords":["orm","mongodb","mysql","redis"],"main":"index.js","engines":{"node":">= v0.4.0"},"dependencies":{"mongoose":">= 2.3.10","redis":">= 0.6.7","mysql":">= 0.9.4","riak-js":">= 0.4.1"},"devDependencies":{"nodeunit":"~0.6.2"},"scripts":{"test":"./run-tests.js"},"_npmUser":{"name":"alexferreira","email":"alex@dsol.com.br"},"_id":"SenseOrm@0.0.4","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.6.2","_defaultsLoaded":true,"dist":{"shasum":"da455fd4d4439e3a7b5ad0b7ea3613e3d18b5490","tarball":"https://registry.npmjs.org/SenseOrm/-/SenseOrm-0.0.4.tgz","integrity":"sha512-aX7fB3LWNAnimWqvDrqvoeHuNOiC78/g/4teeKG75Wz4VJN54fjdoMQFJR6hCxUhu7JRURrpCd1lPcf5j+IsRw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCou4GZdOLhr9h5y29vKZF16NOz6VThZ0/qaY6MiHY6jgIgQfDhMe3QSbdgCrXc6oWt+3xo+dZVdGTgLoL17HKJ3HA="}]},"maintainers":[{"name":"alexferreira","email":"alex@dsol.com.br"}]},"0.0.5":{"author":{"name":"Alex Ferreira"},"name":"SenseOrm","version":"0.0.5","description":"ORM for every database: mongodb, mysql, redis","keywords":["orm","mongodb","mysql","redis"],"main":"index.js","engines":{"node":">= v0.4.0"},"dependencies":{"mongoose":">= 2.3.10","redis":">= 0.6.7","mysql":">= 0.9.4","riak-js":">= 0.4.1"},"devDependencies":{"nodeunit":"~0.6.2"},"scripts":{"test":"./run-tests.js"},"_npmUser":{"name":"alexferreira","email":"alex@dsol.com.br"},"_id":"SenseOrm@0.0.5","_engineSupported":true,"_npmVersion":"1.1.0-beta-10","_nodeVersion":"v0.6.6","_defaultsLoaded":true,"dist":{"shasum":"2ed61bc225b0502ce066a40cb0cfb28615b1afd8","tarball":"https://registry.npmjs.org/SenseOrm/-/SenseOrm-0.0.5.tgz","integrity":"sha512-m5+dGTL957zVxogLenzG7eIDODSjDfymXkQhFL6hmGjs2UNHw8tCoNurnd162JPBBrQAxlaLTgOMjZ5oj12ciQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDhtnUbAypQgY7Po2/Nk053e+Knh7L3mLlzQxaZWVt1bAIgKyLpCAIPcyChzaX76lJqJtT4QQKXXZAi9He0GjPsoCc="}]},"maintainers":[{"name":"alexferreira","email":"alex@dsol.com.br"}]}},"readme":"## About\n\nSenseOrm is cross-db ORM, providing **common interface** to access most popular database formats.\nCurrently supported are: mongodb, redis, mysql and js-memory-storage. You can add your favorite database adapter, checkout one of the existing adapters to learn how, it's super-easy, I guarantee.\n\n## Installation\n\n    npm install senseorm\n\n## Usage\n\n    var Schema = require('senseorm').Schema;\n    var s = new Schema('mongoose');\n    // define models\n    var Post = schema.define('Post', {\n        title:     { type: String, length: 255 },\n        content:   { type: Schema.Text },\n        date:      { type: Date,    default: Date.now },\n        published: { type: Boolean, default: false }\n    });\n    // simplier way to describe model\n    var User = schema.define('User', {\n        name:         String,\n        bio:          Schema.Text,\n        approved:     Boolean,\n        joinedAt:     Date,\n        age:          Number\n    });\n\n    // setup relationships\n    User.hasMany(Post,   {as: 'posts',  foreignKey: 'user_id'});\n    // creates instance methods:\n    // user.posts(conds)\n    // user.posts.build(data) // like new Post({user_id: user.id});\n    // user.posts.create(data) // build and save\n\n    Post.belongsTo(User, {as: 'author', foreignKey: 'user_id'});\n    // creates instance methods:\n    // post.author(callback) -- getter when called with function\n    // post.author() -- sync getter when called without params\n    // post.author(user) -- setter when called with object\n\n    s.automigrate(); // required only for mysql NOTE: it will drop User and Post tables\n\n    // work with models:\n    var user = new User;\n    user.save(function (err) {\n        var post = user.posts.build({title: 'Hello world'});\n        post.save(console.log);\n    });\n\n    // Common API methods\n\n    // just instantiate model\n    new Post\n    // save model (of course async)\n    Post.create(cb);\n    // all posts\n    Post.all(cb)\n    // all posts by user\n    Post.all({userId: user.id});\n    // the same as prev\n    user.posts(cb)\n    // same as new Post({userId: user.id});\n    user.posts.build\n    // save as Post.create({userId: user.id}, cb);\n    user.posts.create(cb)\n    // find instance by id\n    User.find(1, cb)\n    // count instances\n    User.count(cb)\n    // destroy instance\n    user.destroy(cb);\n    // destroy all instances\n    User.destroyAll(cb);\n\n    // Setup validations\n    User.validatesPresenceOf('name', 'email')\n    User.validatesLengthOf('password', {min: 5, message: {min: 'Password is too short'}});\n    User.validatesInclusionOf('gender', {in: ['male', 'female']});\n    User.validatesExclusionOf('domain', {in: ['www', 'billing', 'admin']});\n    User.validatesNumericalityOf('age', {int: true});\n\n    user.isValid() // false\n    user.errors // hash of errors {attr: [errmessage, errmessage, ...], attr: ...}\n\nRead the tests for usage examples: ./test/common_test.js\n\n## Running tests\n\nAll tests are written using nodeunit:\n\n    nodeunit test/common_test.js\n\nIf you run this line, of course it will fall, because it requres different databases to be up and running, but you can use js-memory-engine out of box! Specify ONLY env var:\n\n    ONLY=memory nodeunit test/common_test.js\n\nof course, if you have mongoose running, you can run\n\n    ONLY=mongoose nodeunit test/common_test.js\n\n## Package structure\n\nNow all common logic described in `./lib/*.js`, and database-specific stuff in `./lib/adapters/*.js`. It's super-tiny, right?\n\n### Common:\n\n+ transparent interface to APIs\n+ -before and -after hooks on save, update, destroy\n+ scopes\n+ default values\n+ more relationships stuff\n+ docs\n\n### Databases:\n\n+ low-level mysql\n+ postgres\n+ mongodb\n+ redis\n+ js-memory-storage\n\n","maintainers":[{"name":"alexferreira","email":"alex@dsol.com.br"}],"time":{"modified":"2022-06-13T02:16:04.400Z","created":"2011-11-14T17:22:22.457Z","0.0.2":"2011-11-14T17:22:24.679Z","0.0.3":"2011-11-18T15:26:08.825Z","0.0.4":"2011-11-26T14:54:41.934Z","0.0.5":"2012-01-06T05:18:22.064Z"},"author":{"name":"Alex Ferreira"}}