https://github.com/dylanlott/wolverinejs
🐺 Real-time event-based library for interacting with MongoDB built with Mongoose.
https://github.com/dylanlott/wolverinejs
mongo mongoose realtime-database
Last synced: 26 days ago
JSON representation
🐺 Real-time event-based library for interacting with MongoDB built with Mongoose.
- Host: GitHub
- URL: https://github.com/dylanlott/wolverinejs
- Owner: dylanlott
- License: lgpl-3.0
- Created: 2017-04-20T21:45:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-26T01:55:59.000Z (about 9 years ago)
- Last Synced: 2025-08-03T01:33:03.137Z (10 months ago)
- Topics: mongo, mongoose, realtime-database
- Language: JavaScript
- Homepage:
- Size: 55.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WolverineJS
🚨🚨🚨
## THIS IS NOT PRODUCTION READY -- DO NOT USE THIS IN PRODUCTION YET.
## THIS LIBRARY IS STILL IN THE EXPERIMENTAL PHASE AND BREAKING CHANGES WILL BE MADE REGULARLY.
🚨🚨🚨
> A realtime event-based Mongo ODM with Socket.io support out of the box.
# Basic API
## create
```javascript
w.create({
model: Example,
body: {
//document model
}
});
```
Emits the `created` event once it has been written to the database. he callback of the created event takes a `data` callback that gives you access to the document that was created.
Emits `error` event if therer were any errors.
## read
### A find many query example:
```javascript
w.get({
model: Example,
query: {
//standard mongoose query params here
},
opts: {
// declare options here
}
});
```
emits a `data` and `error` event.
### a find one / find by ID example:
```javascript
w.get({
model: Example,
id:
});
```
emits the `data` and `error` events.
## update
```
w.update({
model: Model,
body: {
test: "updated value"
},
opts: {
upsert: true
}
});
```
emits the `updated` and `error` events.
`updated` event passes through a callback with the previous model's data and the updated version of the model.
## delete
```
// delete by query
w.delete({
model: Model,
query: {
test: "value"
},
options: {
options: true
}
});
// delete by ID
w.delete({
model: Model,
id: _id
});
```
emits the `deleted` and `error` events.
## Events
- All events are tied to a model
e.g. `Model.on('created')`
- Data callbacks have a meta object that give information such as how many documents were touched, how many were modified, how many were created, a timestamp, etc...
## TODO:
- Figure out schemas and model registration on top of mongoose
- Tie in for REST API generation
-