0.2.0 • Published 6 years ago

ilorm-connector-mongo v0.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Ilorm-connector-mongodb

The ilorm connector to MongoDB.

MongoQuery

An ilorm model binded with the ilorm connector mongoDB. Could use a powerful extension of the Ilorm Query : IlormMongoQuery

Aggregate

const query = UserModel.query();

query
    .firstName.is('Sam')
    .match() // Declare a match aggregator stage
    .gender.isKey()
    .age.avg('avgAge')
    .count('totalUser')
    .group()
    .run()
    
This code will be converted to the aggregate query :
[
    {
        $match: {
            firstName: 'Sam'
        }
    },
    {
        $group: {
            _id: '$gender',
            avgAge: { $avg: '$age' },
            totalUser: { $sum: 1 }
        }
    }
]




]