Add an example for repository access
igorshapiro opened this issue · 1 comments
igorshapiro commented
async findByName(name) {
const repository = await Q.Models.User.repository
const collection = repository.adapter.client.collection('users')
return collection.find({ name }).toArray()
}
ondrej-kvasnovsky commented
Because what I need, is mongo collection, I just injected mongo into my class, something like this.
module.exports = class {
constructor(mongo) {
this.mongo = mongo
}
async userCollection() {
return this.mongo.collection('user')
}
}```
I think this is more clear, better than through Q.Models