couchbase-model-decorator
v1.0.0
Published
My terrific module
Downloads
6
Readme
couchbase-model-decorator
Install
$ npm install --save couchbase-model-decorator
Usage
orm.js
:
import path from 'path';
import couchbase from 'couchbase';
import couchbaseModelDecorator from 'couchbase-model-decorator';
const cluster = new couchbase.Cluster();
const bucket = cluster.openBucket();
export const model = couchbaseModelDecorator(bucket);
models/user.js
:
import Joi from 'joi';
import {model} from './orm';
@model('user')
export default class {
username = Joi.string().alphanum();
password = Joi.string();
email = Joi.string();
}
import user from './models/user';
user.insert({
username: 'user',
password: 'pass',
email: '[email protected]'
})
.then(result => {
console.log(result);
})
API
couchbaseModelDecorator(couchbaseBucket)
return a decorator method which can be used on models
couchbaseBucket
Type: Bucket
couchbase bucket to which we will connect to
License
MIT © Thomas Sileghem