{"id":15561855,"url":"https://github.com/doodzik/mangosta","last_synced_at":"2025-03-29T04:43:04.835Z","repository":{"id":11894886,"uuid":"14457670","full_name":"doodzik/mangosta","owner":"doodzik","description":"fixtures/factory library for mongoose","archived":false,"fork":false,"pushed_at":"2014-09-26T20:57:50.000Z","size":420,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-09T05:47:24.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://doodzik.github.io/mangosta","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doodzik.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-16T23:43:20.000Z","updated_at":"2014-09-26T20:57:50.000Z","dependencies_parsed_at":"2022-09-07T02:50:31.934Z","dependency_job_id":null,"html_url":"https://github.com/doodzik/mangosta","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodzik%2Fmangosta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodzik%2Fmangosta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodzik%2Fmangosta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodzik%2Fmangosta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doodzik","download_url":"https://codeload.github.com/doodzik/mangosta/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140540,"owners_count":20729797,"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-02T16:10:28.750Z","updated_at":"2025-03-29T04:43:04.818Z","avatar_url":"https://github.com/doodzik.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[quote]\n#ATTENTION\nTHIS MODULE ISN'T MAINTAINTED ANYMORE.\nUSE STUBS/MOCKS IN YOUR SPECS/TESTS INSTEAD OF ACCESSING THE DATABASE.\n[/quote]\n\n# Overview\n\nMangosta (esp. for mongoose) is a factory library for mongoose, which provides a simple but powerful interface.\n\nPLEASE REPORT ANY BUGS OR ENHANCEMENTS\n\n# Installation\n\n$ npm install mangosta\n\nif you want the unstable 1.1.0 release, which supports nested schemas, clone this repository.\n\n# User Guide\n\nfind the API under: http://doodzik.github.io/mangosta\n\n###Factory file\n__dirname/test/factory/test_factory.js\n\n```javascript\nvar factory, test_factory1, Factory, mongoose;\n\nmongoose = require('mongoose');\nFactory = require('mangosta');\nmodel = mongoose.model(\"factory\");//get model, which was previously created\n// or in v1.1.0 you can also use\nmodel = \"factory\";\n\ntest_factory1 = require(__dirname/test/factory/test_factory.js);\n\nfactory = new Factory(model, function() {\n  return {\n    key: value,\n    $child: { // child factory -\u003e isnt going to be in the doc\n      // define child factory as an object or a function\n      // define child as function if it is important that the child is build on every build/create operation \n      //   -\u003e for example another factory\n      child_name: function() {\n        return {\n          key: value\n        };\n      },\n      child_name: {\n        key: value\n        $child: {\n          child_name: function() {\n            //example of another factory in a factory -\u003e call this as a regular child no changes needed\n            var $docs;\n            test_factory1.build({}, function(err, doc){\n              $docs = doc;\n            });\n            return {\n              firstName: $docs.test\n            };\n          }\n        }\n      }\n    }\n  }\n});\n\nmodule.exports = factory;\n```\n\n###Test file\n__dirname/test/index.js\n\n```javascript\n\nfactory = require(\"./factories/test_factory.js\");\n\n//build and create accept the same parameters\nfactory.create(obj, callback)\nfactory.build(obj, callback)\n\n// if single document return object else Array Object\n// create return same param as model.create\ncallback = function(err, docs) {}\n\nobj =\n  {\n    $seq: Int,\n    // reset seq to given num\n    $factory: String,\n    // if factory isnt defined use the default factory \n    $docs:[ \n    //or $doc but then without the squared brackets\n    //you can skip every key -\u003e you can parse a empty object\n      {\n        // if the factory isnt defined use the factory of the parent\n        $factory: String,\n        //define how many of these object should be created\n        $num: Int,\n        // you can modify the values of the factory\n        key: value\n      }\n      //add objects here to create multi num document with different factory \n      //or/and value for key of main factory\n    ]\n  };;\n\n// if you wish you can access the model directly by factory.model\n\n// string methods\n// just include them in the value\n// please visit the strgMethods module to see what you can do\n// https://github.com/doodzik/strg_methods\n\n```\n\nor to see more examples look at the testfile\n\n# License\n\n(The MIT License)\n\nCopyright (c) 2013 doodzik \u003c4004blog@gmail.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoodzik%2Fmangosta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoodzik%2Fmangosta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoodzik%2Fmangosta/lists"}