An open API service indexing awesome lists of open source software.

https://github.com/ccrisrober/bookshelf-crud


https://github.com/ccrisrober/bookshelf-crud

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# Bookshelf-crud
Simple CRUD for Bookshelf models

## How to use
```javascript
var bookshelf = require("bookshelf");
// ...
bookshelf.plugin(require("bookshelf-crud"));
```

## Examples
```javascript
User.findAll({password: "12345678"})
User.findAll({password: "12345678", "email": "[email protected]"})
User.findOne({email: "[email protected]"})
User.findOne({id: 2})
User.findById(2)
User.create({
email: "[email protected]",
password: "666666666",
name: "Follow the leader"
})
User.updateOrCreate({
id: 115
}, {
email: "[email protected]",
password: "666666666",
name: "Follow me"
})
User.destroy({id: 4})
User.update({
id: 500
}, {
username: "Joselito1"
})
.then(function(user) {
res.json(user);
})
.catch(function(err) {
res.json(err);
});
```