I want to use LoopbackJS framework to write some quick APIs.
The thing is that I want to connect my model with the mongodb loopback connector to do some simple find queries.
These are my files:
/server/model-config.js
"transaction": {
"dataSource": "mongo",
"public": true
}
/server/datasources.json
"mongo": {
"name": "mongo",
"connector": "mongodb"
}
/common/models/transaction.js
module.exports = function(Transaction) {
Transaction.find({}, function(err, data) {
console.log(data);
});
};
The following is failing with this error:
Error: Cannot call transaction.find(). The find method has not been setup. The PersistedModel has not been correctly attached to a DataSource!
What am I doing wrong?