{"id":17736586,"url":"https://github.com/parro-it/ngoose","last_synced_at":"2025-03-31T19:17:05.837Z","repository":{"id":65458257,"uuid":"48662916","full_name":"parro-it/ngoose","owner":"parro-it","description":"javascript object factory with defaults","archived":false,"fork":false,"pushed_at":"2016-01-13T22:43:16.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T20:01:40.792Z","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":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parro-it.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","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-12-27T22:31:23.000Z","updated_at":"2019-07-09T11:52:16.000Z","dependencies_parsed_at":"2023-01-24T13:15:25.495Z","dependency_job_id":null,"html_url":"https://github.com/parro-it/ngoose","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fngoose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fngoose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fngoose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fngoose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parro-it","download_url":"https://codeload.github.com/parro-it/ngoose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246523847,"owners_count":20791444,"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-10-26T00:23:34.408Z","updated_at":"2025-03-31T19:17:05.801Z","avatar_url":"https://github.com/parro-it.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ngoose\n\n\u003e javascript object factory with defaults.\n\nngoose does one thing well: it create new objects with default fields values based on a schema definition.\n\n\n[![Travis Build Status](https://img.shields.io/travis/parro-it/ngoose.svg)](http://travis-ci.org/parro-it/ngoose)\n[![NPM module](https://img.shields.io/npm/v/ngoose.svg)](https://npmjs.org/package/ngoose)\n[![NPM downloads](https://img.shields.io/npm/dt/ngoose.svg)](https://npmjs.org/package/ngoose)\n\n[![Test Coverage](https://codeclimate.com/github/parro-it/ngoose/badges/coverage.svg)](https://codeclimate.com/github/parro-it/ngoose/coverage)\n[![Code Climate](https://codeclimate.com/github/parro-it/ngoose.png)](https://codeclimate.com/github/parro-it/ngoose)\n[![Issue Count](https://codeclimate.com/github/parro-it/ngoose/badges/issue_count.svg)](https://codeclimate.com/github/parro-it/ngoose)\n\n## Installation\n\n```bash\nnpm install --save ngoose\n```\n## Usage\n\n```js\nconst model = require('ngoose');\n\nconst user = model({\n  age: Number,\n  name: String\n});\n\nconst instance = user();\nconsole.log(instance);\n```\n\u003e {\n\u003e   age: 0,\n\u003e   name: \"\"\n\u003e }\n\nYou can supply data to the factory method:\n\n```js\nconst instance = user({\n  name: 'Garibaldi'\n});\nconsole.log(instance);\n```\n\u003e {\n\u003e   age: 0,\n\u003e   name: \"Garibaldi\"\n\u003e }\n\nSupplied fields that are not defined in schema are not inserted in created instance:\n\n```js\nconst instance = user({\n  name: 'Garibaldi',\n  address: 'somewhere'\n});\nconsole.log(instance);\n```\n\u003e {\n\u003e   age: 0,\n\u003e   name: \"Garibaldi\"\n\u003e }\n\n\n\nYou can specify default values in schema:\n\n```js\nconst user = model({\n  address: [String, 'somewhere'],\n  name: [String, 'Garibaldi']\n});\n\nconst instance=user();\nconsole.log(instance);\n```\n\u003e {\n\u003e   address: \"somewhere\",\n\u003e   name: \"Garibaldi\"\n\u003e }\n\n\nYou can compose models with other models or with inlined objects:\n\n```js\n  const user = model({\n     name: [String, 'unknown'],\n     cool: [Boolean, true]\n  });\n\n  const bill = model({\n     customer: user,\n     payment: {\n        terms: String,\n        days: [Number, 30]\n     }\n  });\n\n  const instance = bill();\n  console.log(instance);\n```\n\u003e {\n\u003e   customer: {\n\u003e     name: 'unknown',\n\u003e     cool: true\n\u003e   },\n\u003e   payment: { terms: '', days: 30 }\n\u003e }\n\n\n## Examples\n\nSee [tests](test.js) for further usage examples.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 parro-it\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparro-it%2Fngoose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparro-it%2Fngoose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparro-it%2Fngoose/lists"}