{"id":18575894,"url":"https://github.com/bevry-archive/backbone-nesty","last_synced_at":"2025-04-10T08:30:57.278Z","repository":{"id":7841218,"uuid":"9212808","full_name":"bevry-archive/backbone-nesty","owner":"bevry-archive","description":"Support nested data types like collections and models within your Backbone.js models","archived":false,"fork":false,"pushed_at":"2023-12-11T09:42:14.000Z","size":51,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-03T01:34:17.408Z","etag":null,"topics":["backbonejs","client-side","nodejs"],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bevry-archive.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-04-04T07:01:11.000Z","updated_at":"2023-12-11T09:42:18.000Z","dependencies_parsed_at":"2024-11-06T23:35:24.610Z","dependency_job_id":null,"html_url":"https://github.com/bevry-archive/backbone-nesty","commit_stats":null,"previous_names":["bevry/backbone-nesty"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bevry-archive%2Fbackbone-nesty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bevry-archive%2Fbackbone-nesty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bevry-archive%2Fbackbone-nesty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bevry-archive%2Fbackbone-nesty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bevry-archive","download_url":"https://codeload.github.com/bevry-archive/backbone-nesty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248185282,"owners_count":21061489,"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":["backbonejs","client-side","nodejs"],"created_at":"2024-11-06T23:22:43.923Z","updated_at":"2025-04-10T08:30:57.267Z","avatar_url":"https://github.com/bevry-archive.png","language":"CoffeeScript","funding_links":["https://patreon.com/bevry","https://opencollective.com/bevry"],"categories":[],"sub_categories":[],"readme":"\u003c!-- TITLE/ --\u003e\n\n\u003ch1\u003eBackbone Nesty\u003c/h1\u003e\n\n\u003c!-- /TITLE --\u003e\n\n\n\u003c!-- BADGES/ --\u003e\n\n\u003cspan class=\"badge-travisci\"\u003e\u003ca href=\"http://travis-ci.org/bevry/backbone-nesty\" title=\"Check this project's build status on TravisCI\"\u003e\u003cimg src=\"https://img.shields.io/travis/bevry/backbone-nesty/master.svg\" alt=\"Travis CI Build Status\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-npmversion\"\u003e\u003ca href=\"https://npmjs.org/package/backbone-nesty\" title=\"View this project on NPM\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/backbone-nesty.svg\" alt=\"NPM version\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-npmdownloads\"\u003e\u003ca href=\"https://npmjs.org/package/backbone-nesty\" title=\"View this project on NPM\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/backbone-nesty.svg\" alt=\"NPM downloads\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-daviddm\"\u003e\u003ca href=\"https://david-dm.org/bevry/backbone-nesty\" title=\"View the status of this project's dependencies on DavidDM\"\u003e\u003cimg src=\"https://img.shields.io/david/bevry/backbone-nesty.svg\" alt=\"Dependency Status\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-daviddmdev\"\u003e\u003ca href=\"https://david-dm.org/bevry/backbone-nesty#info=devDependencies\" title=\"View the status of this project's development dependencies on DavidDM\"\u003e\u003cimg src=\"https://img.shields.io/david/dev/bevry/backbone-nesty.svg\" alt=\"Dev Dependency Status\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cbr class=\"badge-separator\" /\u003e\n\u003cspan class=\"badge-patreon\"\u003e\u003ca href=\"https://patreon.com/bevry\" title=\"Donate to this project using Patreon\"\u003e\u003cimg src=\"https://img.shields.io/badge/patreon-donate-yellow.svg\" alt=\"Patreon donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-opencollective\"\u003e\u003ca href=\"https://opencollective.com/bevry\" title=\"Donate to this project using Open Collective\"\u003e\u003cimg src=\"https://img.shields.io/badge/open%20collective-donate-yellow.svg\" alt=\"Open Collective donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-gratipay\"\u003e\u003ca href=\"https://www.gratipay.com/bevry\" title=\"Donate weekly to this project using Gratipay\"\u003e\u003cimg src=\"https://img.shields.io/badge/gratipay-donate-yellow.svg\" alt=\"Gratipay donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-flattr\"\u003e\u003ca href=\"https://flattr.com/profile/balupton\" title=\"Donate to this project using Flattr\"\u003e\u003cimg src=\"https://img.shields.io/badge/flattr-donate-yellow.svg\" alt=\"Flattr donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-paypal\"\u003e\u003ca href=\"https://bevry.me/paypal\" title=\"Donate to this project using Paypal\"\u003e\u003cimg src=\"https://img.shields.io/badge/paypal-donate-yellow.svg\" alt=\"PayPal donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-bitcoin\"\u003e\u003ca href=\"https://bevry.me/bitcoin\" title=\"Donate once-off to this project using Bitcoin\"\u003e\u003cimg src=\"https://img.shields.io/badge/bitcoin-donate-yellow.svg\" alt=\"Bitcoin donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-wishlist\"\u003e\u003ca href=\"https://bevry.me/wishlist\" title=\"Buy an item on our wishlist for us\"\u003e\u003cimg src=\"https://img.shields.io/badge/wishlist-donate-yellow.svg\" alt=\"Wishlist browse button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cbr class=\"badge-separator\" /\u003e\n\u003cspan class=\"badge-slackin\"\u003e\u003ca href=\"https://slack.bevry.me\" title=\"Join this project's slack community\"\u003e\u003cimg src=\"https://slack.bevry.me/badge.svg\" alt=\"Slack community badge\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\n\u003c!-- /BADGES --\u003e\n\n\n\u003c!-- DESCRIPTION/ --\u003e\n\nSupport nested data types like collections and models within your Backbone.js models\n\n\u003c!-- /DESCRIPTION --\u003e\n\n\n\u003c!-- INSTALL/ --\u003e\n\n\u003ch2\u003eInstall\u003c/h2\u003e\n\n\u003ca href=\"https://npmjs.com\" title=\"npm is a package manager for javascript\"\u003e\u003ch3\u003eNPM\u003c/h3\u003e\u003c/a\u003e\u003cul\u003e\n\u003cli\u003eInstall: \u003ccode\u003enpm install --save backbone-nesty\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003eModule: \u003ccode\u003erequire('backbone-nesty')\u003c/code\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003ca href=\"http://browserify.org\" title=\"Browserify lets you require('modules') in the browser by bundling up all of your dependencies\"\u003e\u003ch3\u003eBrowserify\u003c/h3\u003e\u003c/a\u003e\u003cul\u003e\n\u003cli\u003eInstall: \u003ccode\u003enpm install --save backbone-nesty\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003eModule: \u003ccode\u003erequire('backbone-nesty')\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003eCDN URL: \u003ccode\u003e//wzrd.in/bundle/backbone-nesty@2.0.0\u003c/code\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003ca href=\"http://enderjs.com\" title=\"Ender is a full featured package manager for your browser\"\u003e\u003ch3\u003eEnder\u003c/h3\u003e\u003c/a\u003e\u003cul\u003e\n\u003cli\u003eInstall: \u003ccode\u003eender add backbone-nesty\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003eModule: \u003ccode\u003erequire('backbone-nesty')\u003c/code\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003ch3\u003e\u003ca href=\"https://github.com/bevry/editions\" title=\"Editions are the best way to produce and consume packages you care about.\"\u003eEditions\u003c/a\u003e\u003c/h3\u003e\n\n\u003cp\u003eThis package is published with the following editions:\u003c/p\u003e\n\n\u003cul\u003e\u003cli\u003e\u003ccode\u003ebackbone-nesty\u003c/code\u003e aliases \u003ccode\u003ebackbone-nesty/index.js\u003c/code\u003e which uses \u003ca href=\"https://github.com/bevry/editions\" title=\"Editions are the best way to produce and consume packages you care about.\"\u003eEditions\u003c/a\u003e to automatically select the correct edition for the consumers environment\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003ebackbone-nesty/source/index.coffee\u003c/code\u003e is Source + CoffeeScript + \u003ca href=\"https://nodejs.org/dist/latest-v5.x/docs/api/modules.html\" title=\"Node/CJS Modules\"\u003eRequire\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003ebackbone-nesty/esnext/index.js\u003c/code\u003e is CoffeeScript Compiled + \u003ca href=\"https://babeljs.io/docs/learn-es2015/\" title=\"ECMAScript Next\"\u003eESNext\u003c/a\u003e + \u003ca href=\"https://nodejs.org/dist/latest-v5.x/docs/api/modules.html\" title=\"Node/CJS Modules\"\u003eRequire\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003ebackbone-nesty/es2015/index.js\u003c/code\u003e is CoffeeScript Compiled + \u003ca href=\"http://babeljs.io/docs/plugins/preset-es2015/\" title=\"ECMAScript 2015\"\u003eES2015\u003c/a\u003e + \u003ca href=\"https://nodejs.org/dist/latest-v5.x/docs/api/modules.html\" title=\"Node/CJS Modules\"\u003eRequire\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003cp\u003eOlder environments may need \u003ca href=\"https://babeljs.io/docs/usage/polyfill/\" title=\"A polyfill that emulates missing ECMAScript environment features\"\u003eBabel's Polyfill\u003c/a\u003e or something similar.\u003c/p\u003e\n\n\u003c!-- /INSTALL --\u003e\n\n\n## Usage\n\n### Example\n\n``` javascript\n// Import\nvar Backbone = require('backbone');\nvar BackboneNestyModel = require('backbone-nesty').BackboneNestyModel;\n\n// Eye Model\nvar EyeModel = Backbone.Model.extend({\n\tattributes: {\n\t\tcolor: null,\n\t\topen: false\n\t}\n});\n\n// Eye Collection\nvar EyeCollection = Backbone.Collection.extend({\n\tmodel: EyeModel\n});\n\n// Mouth Model\nvar MouthModel = Backbone.Model.extend({\n\tattributes: {\n\t\topen: false\n\t}\n});\n\n// Head Model\nvar HeadModel = BackboneNestyModel.extend({\n\t// Define our nested collections\n\tcollections: {\n\t\teyes: EyeCollection\n\t},\n\n\t// Define our nested models\n\tmodels: {\n\t\tmouth: MouthModel\n\t}\n});\n\n// Instantiate our head with our nested data\nvar myHead = new HeadModel({\n\t// will create a mouth model with this data\n\tmouth: {\n\t\topen: true\n\t},\n\t// will create an eyes collection with this data\n\teyes: [\n\t\t// will create an eye model with this data\n\t\t{\n\t\t\tid: 'left',\n\t\t\tcolor: 'green',\n\t\t\topen: true\n\t\t},\n\t\t// will create an eye model with this data\n\t\t{\n\t\t\tid: 'right',\n\t\t\tcolor: 'green',\n\t\t\topen: true\n\t\t}\n\t]\n});\n\n// Check\nconsole.log(myHead.toJSON());\nconsole.log(myHead.get('eyes.left.open')); // true\n// ^ equiv to myHeader.get('eyes').get('left').get('open')\n\n// Nested Setter\nmyHead.set('eyes.left.open', false);\n// ^ equiv to myHeader.get('eyes').get('right').set('open', false)\n\n// Check\nconsole.log(myHead.toJSON());\nconsole.log(myHead.get('eyes.left.open')); // false\n```\n\n### BackboneNestyModel API\n\n`require('backbone-nesty').BackboneNestyModel` is an extended [Backbone.js](http://backbonejs.org/) [Model](http://backbonejs.org/#Model) that adds the following functionality:\n\n- properties\n\t- `collections` defaults to `{}`, an object which keys are the attributes and values are the collection data type for the attribute\n\t- `models` defaults to `{}`, an object which keys are the attributes and values are the model data type for the attribute\n\t- `embed` defaults to `{}`, an object which keys are the attributes and values are boolean on whether or not we should embed the full data of this attribute when calling `toJSON` on the model or just an id listing\n\t- `strict` defaults to `true`, a boolean for whether or not we should allow unknown attributes to be set on our model\n- methods\n\t- `toJSON()` will serialize the model and all nested data types as well, if the embed property for an nested data type is false, that value will be replaced with an id listing instead\n\t- `get(key)` adds support for nested gets\n\t- `set(attrs,opts)` adds support for nested sets and will instantiate the value according to the nested data type if applicable\n\n\u003c!-- HISTORY/ --\u003e\n\n\u003ch2\u003eHistory\u003c/h2\u003e\n\n\u003ca href=\"https://github.com/bevry/backbone-nesty/blob/master/HISTORY.md#files\"\u003eDiscover the release history by heading on over to the \u003ccode\u003eHISTORY.md\u003c/code\u003e file.\u003c/a\u003e\n\n\u003c!-- /HISTORY --\u003e\n\n\n\u003c!-- CONTRIBUTE/ --\u003e\n\n\u003ch2\u003eContribute\u003c/h2\u003e\n\n\u003ca href=\"https://github.com/bevry/backbone-nesty/blob/master/CONTRIBUTING.md#files\"\u003eDiscover how you can contribute by heading on over to the \u003ccode\u003eCONTRIBUTING.md\u003c/code\u003e file.\u003c/a\u003e\n\n\u003c!-- /CONTRIBUTE --\u003e\n\n\n\u003c!-- BACKERS/ --\u003e\n\n\u003ch2\u003eBackers\u003c/h2\u003e\n\n\u003ch3\u003eMaintainers\u003c/h3\u003e\n\nThese amazing people are maintaining this project:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"http://balupton.com\"\u003eBenjamin Lupton\u003c/a\u003e — \u003ca href=\"https://github.com/bevry/backbone-nesty/commits?author=balupton\" title=\"View the GitHub contributions of Benjamin Lupton on repository bevry/backbone-nesty\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003ch3\u003eSponsors\u003c/h3\u003e\n\nThese amazing people have contributed finances to this project:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"http://www.govests.com.au\"\u003eGoVests\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\nBecome a sponsor!\n\n\u003cspan class=\"badge-patreon\"\u003e\u003ca href=\"https://patreon.com/bevry\" title=\"Donate to this project using Patreon\"\u003e\u003cimg src=\"https://img.shields.io/badge/patreon-donate-yellow.svg\" alt=\"Patreon donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-opencollective\"\u003e\u003ca href=\"https://opencollective.com/bevry\" title=\"Donate to this project using Open Collective\"\u003e\u003cimg src=\"https://img.shields.io/badge/open%20collective-donate-yellow.svg\" alt=\"Open Collective donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-gratipay\"\u003e\u003ca href=\"https://www.gratipay.com/bevry\" title=\"Donate weekly to this project using Gratipay\"\u003e\u003cimg src=\"https://img.shields.io/badge/gratipay-donate-yellow.svg\" alt=\"Gratipay donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-flattr\"\u003e\u003ca href=\"https://flattr.com/profile/balupton\" title=\"Donate to this project using Flattr\"\u003e\u003cimg src=\"https://img.shields.io/badge/flattr-donate-yellow.svg\" alt=\"Flattr donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-paypal\"\u003e\u003ca href=\"https://bevry.me/paypal\" title=\"Donate to this project using Paypal\"\u003e\u003cimg src=\"https://img.shields.io/badge/paypal-donate-yellow.svg\" alt=\"PayPal donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-bitcoin\"\u003e\u003ca href=\"https://bevry.me/bitcoin\" title=\"Donate once-off to this project using Bitcoin\"\u003e\u003cimg src=\"https://img.shields.io/badge/bitcoin-donate-yellow.svg\" alt=\"Bitcoin donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-wishlist\"\u003e\u003ca href=\"https://bevry.me/wishlist\" title=\"Buy an item on our wishlist for us\"\u003e\u003cimg src=\"https://img.shields.io/badge/wishlist-donate-yellow.svg\" alt=\"Wishlist browse button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\n\u003ch3\u003eContributors\u003c/h3\u003e\n\nThese amazing people have contributed code to this project:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"http://balupton.com\"\u003eBenjamin Lupton\u003c/a\u003e — \u003ca href=\"https://github.com/bevry/backbone-nesty/commits?author=balupton\" title=\"View the GitHub contributions of Benjamin Lupton on repository bevry/backbone-nesty\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003ca href=\"https://github.com/bevry/backbone-nesty/blob/master/CONTRIBUTING.md#files\"\u003eDiscover how you can contribute by heading on over to the \u003ccode\u003eCONTRIBUTING.md\u003c/code\u003e file.\u003c/a\u003e\n\n\u003c!-- /BACKERS --\u003e\n\n\n\u003c!-- LICENSE/ --\u003e\n\n\u003ch2\u003eLicense\u003c/h2\u003e\n\nUnless stated otherwise all works are:\n\n\u003cul\u003e\u003cli\u003eCopyright \u0026copy; \u003ca href=\"http://bevry.me\"\u003eBevry Pty Ltd\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\nand licensed under:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"http://spdx.org/licenses/MIT.html\"\u003eMIT License\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003c!-- /LICENSE --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbevry-archive%2Fbackbone-nesty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbevry-archive%2Fbackbone-nesty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbevry-archive%2Fbackbone-nesty/lists"}