{"id":20428899,"url":"https://github.com/ppmathis/modelize","last_synced_at":"2025-06-17T10:09:19.296Z","repository":{"id":6116654,"uuid":"7344572","full_name":"ppmathis/modelize","owner":"ppmathis","description":"Simple ORM written in JavaScript","archived":false,"fork":false,"pushed_at":"2012-12-31T16:01:19.000Z","size":140,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T21:08:47.831Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"blocktrail/blocktrail-sdk-nodejs","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ppmathis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-27T19:02:03.000Z","updated_at":"2015-11-05T15:38:17.000Z","dependencies_parsed_at":"2022-09-13T21:23:27.702Z","dependency_job_id":null,"html_url":"https://github.com/ppmathis/modelize","commit_stats":null,"previous_names":["neoxid/modelize"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ppmathis/modelize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppmathis%2Fmodelize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppmathis%2Fmodelize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppmathis%2Fmodelize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppmathis%2Fmodelize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ppmathis","download_url":"https://codeload.github.com/ppmathis/modelize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppmathis%2Fmodelize/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260336341,"owners_count":22993739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T07:29:23.132Z","updated_at":"2025-06-17T10:09:14.273Z","avatar_url":"https://github.com/ppmathis.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Modelize #\n\n[![build status](https://secure.travis-ci.org/NeoXiD/modelize.png)](http://travis-ci.org/NeoXiD/modelize)\n\nModelize is a simple ORM written in JavaScript.\n\n## License ##\nApache License (version 2)\n\n## Prerequisites ##\nModelize requires version 0.6.x of Node.js or higher. If you want to run the tests or work on model, you'll want [Vows](https://github.com/cloudhead/vows).\n\n## Installing with [NPM](http://npmjs.org) ##\n\n```\nnpm install modelize\n```\n\n## Adapters ##\nModelize currently implements an in-memory store. More adapters will follow, a socket.io binding is also planned.\n\n## Defining models\nModelize uses a simple syntax for defining a model. It will look like this:\n\n```javascript\nvar UserModel = new Modelize('User', function() {\n\tthis.adapter('memory');\n\tthis.property('username', 'string', { required: true });\n\tthis.property('password', 'string', { required: true });\n\tthis.property('firstName', 'string', { defaultValue: 'John' });\n\tthis.property('lastName', 'string', { defaultValue: 'Doe' });\n});\n```\n\nThe following data types are currently supported:\n\n- string\n- number\n- array\n- object\n\n## Creating instances ##\nNow you can create instances of your new fancy User model. It is easy too:\n\n```javascript\nvar user = UserModel.create({\n\tusername: 'jdoe',\n\tpassword: 'fancymodels',\n\tlastName: 'Smith'\n});\n```\n\n## Getting and setting properties\nJust use the following syntax:\n\n```javascript\n// Getting properties\nconsole.log(user.username());\nconsole.log(user.password());\n\n// Setting properties\nuser.password('modelize');\n```\n\nIf you try to get a property which was not initialized yet, it will return the default value or undefined if there is none.\n\n## Saving \u0026 Deleting of model instances ##\n**Remember:** You must initialize/set all required properties before saving the model. Otherwise Modelize will throw an error. \n\n```javascript\nuser.save(); // Saves the model instance into the store\nuser.password('nodejs');\nuser.save(); // Updates the model instance in the store\nuser.remove(); // Removes the model instance from the store\n```\n\n## Querying ##\nModelize offers a simple API for finding and sorting existing items/instances. Please remember, that an instance can only be found, if ```instance.save()``` was called.\n\nThe API is (as you might expect for a NodeJS library) asynchronous and the methods for querying are static methods on each model constructor.\n\n### Shared instances ###\nInstances are always shared to save memory usage and keep the usage simple. This means:\n\n```javascript\nvar user1 = UserModel.create({\n\tlastName: 'Doe'\n});\nvar user2 = UserModel.create({\n\tlastName: 'Doe'\n});\n\nUserModel.find({lastName: 'Doe'}, function(err, data) {\n\t// data[0] is the same instance as user1\n\t// data[1] is the same instance as user2\n\n\tuser1.lastName('Smith');\n\tconsole.log(user1.lastName() == data[0].lastName()) // Is true\n});\n```\n\n### Finding a single item ###\nUse the ```findOne``` method to find a single item. You can specify a set of query parameters in the form of an object-literal. In the case of multiple results, it will only return the first one. If no result can be found, the return value is ```undefined```.\n\n```javascript\nUserModel.findOne({username: 'jdoe'}, function(err, user) {\n\tif(err) throw err;\n\tif(user === undefined) throw new Error('User not found!');\n\tconsole.log(user);\n});\n```\n\n### Collection of items ###\nUse the ```find``` method to find lots of items. Pass it a set of query parameters in the form of an object-literal, where each key is a field to compare and the value is a simple value for comparison. (equal to)\n\n```javascript\nUserModel.find({lastName: 'Smith'}, function(err, data) {\n\tif(err) throw err;\n\t// Data is now array filled with all results found\n});\n```\n\nIf you want to compare an object, you can also give a set of query parameters like this: ```{stats: {experience: 37, age: 19}}```\n\n- - -\nModelize Javascript ORM - © 2012-2013 P. Mathis (pmathis@snapserv.net)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppmathis%2Fmodelize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fppmathis%2Fmodelize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppmathis%2Fmodelize/lists"}