{"id":21926691,"url":"https://github.com/tsand/snowstorm","last_synced_at":"2025-07-14T08:07:21.482Z","repository":{"id":40580170,"uuid":"41125065","full_name":"tsand/snowstorm","owner":"tsand","description":"Simple Javascript ORM","archived":false,"fork":false,"pushed_at":"2023-06-01T03:56:44.000Z","size":79,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T04:19:23.955Z","etag":null,"topics":["javascript","javascript-orm","orm"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsand.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":"2015-08-21T00:27:47.000Z","updated_at":"2021-01-18T15:06:11.000Z","dependencies_parsed_at":"2022-08-09T23:40:58.364Z","dependency_job_id":null,"html_url":"https://github.com/tsand/snowstorm","commit_stats":null,"previous_names":["theisensanders-wf/snowstorm"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsand%2Fsnowstorm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsand%2Fsnowstorm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsand%2Fsnowstorm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsand%2Fsnowstorm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsand","download_url":"https://codeload.github.com/tsand/snowstorm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244952806,"owners_count":20537474,"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":["javascript","javascript-orm","orm"],"created_at":"2024-11-28T22:10:41.383Z","updated_at":"2025-03-22T12:14:02.313Z","avatar_url":"https://github.com/tsand.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# snowstorm\n\n[![npm version](https://img.shields.io/npm/v/snowstorm)](https://www.npmjs.com/package/snowstorm)\n[![Node.js Build](https://github.com/tsand/snowstorm/workflows/Node.js%20Build/badge.svg)](https://github.com/tsand/snowstorm/actions)\n\nSimple Javascript ORM\n\n## :snowflake: Getting Started\n\n### Installation\n\n`npm install snowstorm`\n\n### Example\n\nCreate a model and define the properties of the model\n\n```js\nvar snowstorm = require('snowstorm');\n\n// Define the model and its properties\nvar Task = snowstorm.create('Task', {\n\ttitle: snowstorm.Properties.string,\n\tcompleted: snowstorm.Properties.boolean,\n\tcreatedAt: snowstorm.Properties.date('created_at')\n});\n```\n\nAdd methods to the prototype layer\n\n```js\nTask.prototype.isCompleted = function () {\n\treturn this.completed;\n};\n```\n\nCreate an instance of a task\n\n```js\n// Data from server\nvar responseData = {\n\ttitle: 'Task out the trash',\n\tcompleted: false,\n\tcreated_at: '2015-08-20T10:00:00.000Z'\n};\nvar task = new Task(responseData);\n```\n\nAccess the properties/methods of the task or convert to JSON to send back to the server\n\n```js\nconsole.log(task.title);          // Task out the trash\nconsole.log(task.createdAt);      // Thu Aug 20 2015 04:00:00 GMT-0600 (MDT)\nconsole.log(task.isCompleted());  // false\n\n// Send back to server\nvar requestData = task.toJSON();\n```\n\n\n## :snowflake: API\n\n**Create a model class**\n\n```js\nsnowstorm.create(name, properties);\n```\n\n---\n\n**Define a property to be used on the model**\n\n```js\nsnowstorm.Properties.string\n// or\nsnowstorm.Properties.string(attr, [arguments])\n```\n\n| Properties                     | Arguments            |\n| ------------------------------ | -------------------- |\n| `snowstorm.Properties.string`  | `attr`               |\n| `snowstorm.Properties.number`  | `attr`               |\n| `snowstorm.Properties.boolean` | `attr`               |\n| `snowstorm.Properties.array`   | `attr`               |\n| `snowstorm.Properties.object`  | `attr`               |\n| `snowstorm.Properties.date`    | `attr`, `format`     |\n| `snowstorm.Properties.model`   | `attr`, `modelClass` |\n\n---\n\n**Create a custom property**\n\n```js\nvar Moment = require('moment'); // https://github.com/moment/moment/\n\nfunction moment (attr) {\n\treturn {\n\t\tattr: attr,\n\t\tconstruct: function (d) {\n\t\t\tif (typeof d === 'undefined') {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn Moment(d);\n\t\t},\n\t\tdestruct: function (d) {\n            if (!d) {\n                return null;\n            }\n\t\t    return d.toISOString();\n\t\t}\n\t}\n};\n\n// Usage\nvar Todo = snowstorm.create('Task', {\n\tdueAt: moment\n});\n```\n\n\n## :snowflake: Running tests\n\n`npm install`\n\n`npm test`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsand%2Fsnowstorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsand%2Fsnowstorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsand%2Fsnowstorm/lists"}