Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deeppatel234/mongoorm-validator
ORM for MongoDB in NodeJS
https://github.com/deeppatel234/mongoorm-validator
mongodb nodejs orm
Last synced: about 1 month ago
JSON representation
ORM for MongoDB in NodeJS
- Host: GitHub
- URL: https://github.com/deeppatel234/mongoorm-validator
- Owner: deeppatel234
- License: mit
- Created: 2018-01-11T17:27:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-13T17:00:23.000Z (almost 7 years ago)
- Last Synced: 2024-10-24T23:18:24.477Z (3 months ago)
- Topics: mongodb, nodejs, orm
- Language: JavaScript
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MongoORM
> MongoDB ORM Framework with Relational Database and Realtime Data Management##### **Create Connection**
***```javascript
var db = require('./mongoorm').db;
var dbConfig = {
dburl: "mongodb://localhost:27017",
dbname: "test"
}
db.connect(dbConfig, function (err) {
if (err) {
console.error('Error in DB Connection : ', err);
}
app.listen(3000, function () {
console.log("Server Started");
});
});
```##### **Create Schema**
***```javascript
// Import
var mongoorm = require('../mongoorm');
var fields = mongoorm.Fields
var Schema = mongoorm.Schemavar studentSchema = new Schema({
'name': fields.String(),
'age': fields.Integer(),
'birthdate': fields.Date(),
'address': {
'city': {
'string': fields.String()
}
}
}, {
strict: true, // Remove data tha not present in Schema
validateBeforeSave: true // Validate Before Save
});
```##### Fields List
***
* Fields.Array()
* Fields.Boolean()
* Fields.Date()
* Fields.Float()
* Fields.Integer()
* Fields.Mixed()
* Fields.ObjectId()
* Fields.String()
##### **Create Collaction**
***```javascript
// Import
var mongoorm = require('../mongoorm');
var Collection = mongoorm.Collection;var studentModel = new Collection('student',studentSchema);
```**Perform Operations on Schema**
```javascript
studentModel.find({}).then(callback);
```##### **Create Record**
***```javascript
var studentRecord = studentModel.create({
name: "deep",
age: 21,
birthdate: '01/09/1996'
address: {
city: 'Mehsana'
}
});
studentRecord.save().then(callback).catch(callback);
```