https://github.com/ccrisrober/bookshelf-crud
https://github.com/ccrisrober/bookshelf-crud
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ccrisrober/bookshelf-crud
- Owner: ccrisrober
- Created: 2016-07-30T16:37:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-08-02T17:29:52.000Z (almost 9 years ago)
- Last Synced: 2025-01-17T07:42:51.906Z (4 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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);
});
```