odme
ODME is not an ODM library. It helps you create a class to keep model logic and has some default logic such as setter, getter, masking and creating id with prefixes. All these behaviours can be changed easily at defining your modle classes. It has an extension to support Couchbase and you can add your own extension to support other storages.
How to use
You can create your model classes extending Base class of odme.
Base = require'odme'Base props: name: schema: Joistring whiteList: true age: schema: Joinumbermin0 whiteList: true total_logins: schema: Joinumbermin0 whiteList: false user = name: 'Arash'age: 32city: 'Sydney'total_logins:10 consolelog userkey #user_mJLGt-e6 consolelog userdoc # { # name: 'Arash', # age: 32, # docType: 'user', # docKey: 'user_mJLGt-e6' # } consolelog usermask # { # name: 'Arash', # age: 32, # docType: 'user', # docKey: 'user_mJLGt-e6' # } user.doc.city = 'Tehran' consolelog userdoc # { # name: 'Arash', # age: 32, # city: 'Tehran', # docType: 'user', # docKey: 'user_mJLGt-e6' # } consolelog usermask # { # name: 'Arash', # age: 32, # docType: 'user', # docKey: 'user_mJLGt-e6' # } consolelog usermask'name,city' # { # name: 'Arash', # city: 'Tehran' # }
You can extend Base class based on your adapters and set a library as source
to store your doc property in key of your model object. Check odme and Couchbase integration here.
Base = require'../build/main'CB db = 'puffer' host: 'localhost'name: 'test' true source: db props: name: schema: Joistring whiteList: true ingredients: schema: JoiarrayitemsJoistring whiteList: true recipe = name: 'Pasta'ingredients: 'pasta''basil''olive oil' consolelog recipekey # recipe_yHr0blT recipesavethen -> #after save you can get it like this Recipegetrecipekeythen consolelog o # return Recipe object
How to read this doc?
Base class is holding all the logic related to how to get a document and store it in the model class and how it will masked on outputs. Extensions such as CB are doing CRUD operations on models.
Need more?
- Find the full list of available methods here.
- This documentation is generated by
groc
, you can make a copy of in your local version. - You can run tests locally by
npm test
. Make sure you have development dependencies installed.