https://github.com/yamadapc/mongoose-access-gen
A really stupid solution for a non-problem: An object's array property access style
https://github.com/yamadapc/mongoose-access-gen
Last synced: 3 months ago
JSON representation
A really stupid solution for a non-problem: An object's array property access style
- Host: GitHub
- URL: https://github.com/yamadapc/mongoose-access-gen
- Owner: yamadapc
- License: mit
- Created: 2013-10-09T23:06:27.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-02-02T17:52:16.000Z (over 9 years ago)
- Last Synced: 2025-01-26T02:16:58.571Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mongoose-access-gen
A little mongoose-plugin for generating array property adders and deleters
## Getting Started
Install the module with: `npm install mongoose-access-gen````javascript
[...]var access = require('mongoose-access-gen');
var ComedianSchema = new Schema({
jokes : [{ type: String }],
laughing: { type: Boolean }
});ComedianSchema.plugin(access);
var Comedian = mongoose.model('Comedian', ComedianSchema),
comedian = new Comedian({
jokes: ['A haskell programmer walks into a bar (...)']
});// Works with arrays
comedian._genAdd('jokes') ('I\'m a C programmer (...)');
comedian._genDel('jokes') ('A haskell programmer walks into a bar (...)');// And values
comedian._genSet('laughing') (true);// And it automatically generates useless methods
var funniest_joke = 'Objective C++ (that\'s all)';comedian.addJoke(funniest_joke);
comedian.jokes.indexOf(funniest_joke) !== -1 // truecomedian.delJoke(funniest_joke);
comedian.jokes.indexOf(funniest_joke) // -1comedian.setLaughing(true);
comedian.laughing // truecomedian.unsetLaughing();
comedian.laughing // undefined[...]
```## License
Copyright (c) 2013 Yamada. Licensed under the MIT license.## Donations
Would you like to buy me a beer? Send bitcoin to 3JjxJydvoJjTrhLL86LGMc8cNB16pTAF3y