Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Yet another Couchbase Orm
$ npm install --save lawson
orm.js
import couchbase from 'couchbase';
import lawson from 'lawson';
const cluster = new couchbase.Cluster();
const bucket = cluster.openBucket();
const lawsonInstance = lawson(bucket);
export const model = lawsonInstance.defineModel;
models/user.js
import {model} from '../orm';
export const default = model('user', {
username: 'string',
email: 'string',
password: 'string'
});
import user from './models/user';
/* create */
user.create({
username: 'test',
email: 'test@test.com',
password: 'secret'
})
/* get */
.then(createdUser => {
return user.get(createdUser.id);
})
/* update */
.then(newUser => {
newUser.username = 'bobby';
return user.update(newUser.id, newUser);
})
.then(updatedUser => {
console.log('user updated');
})
.then(() => {
return user.query({
where: {
username: 'bobby'
}
});
})
.then(users => {
console.log(user.length);
// => 1
return user.delete(users[0].id);
})
.catch(e => {
console.warn(e);
});
Create a new instance of lawson
Type: Bucket
required
The bucket the library is storing documents
Define a new model
Type: string
required
the type of the document
Type: object
required
The schema of the document, see its definition here
Returns a Promise, that resolve to the requested document
Type: string
required
Returns a Promise, that resolve when the document is updated
Type: string
required
the id of the document to update
Type: object
required
the new version of the document that will be updated
Returns a Promise, that resolve to the created document
Type: object
required
The document that will be created
Returns a Promise when the document is deleted
Type: string
required
The id of the document that will be deleted
Returns a Promise, that resolve to all the documents
Type: object
Used to filter out results of the query
Type: number
The number of documents to return
Type: number
default: 0
The number of documents to skip
Lawson | Ottoman | |
---|---|---|
Mock-able | Yes | No |
Use S1-Ql (faster) | planned | Yes |
MIT © Thomas Sileghem
FAQs
Database agnostic ODM
The npm package lawson receives a total of 3 weekly downloads. As such, lawson popularity was classified as not popular.
We found that lawson demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.