I am getting error: Error: Cannot call Test.create(). The create method has not been setup The PersistedModel has not been correctly attached to a datasource.
Here is my datasource.json:
{
"db": {
"name": "db",
"connector": "memory"
},
"mongoDS": {
"host": "localhost",
"port": 27017,
"name": "mongoDS",
"database": "akhiltest",
"connector": "mongodb"
}
}
model-config.json:
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"User": {
"dataSource": "db"
},
"AccessToken": {
"dataSource": "db",
"public": false
},
"ACL": {
"dataSource": "db",
"public": false
},
"RoleMapping": {
"dataSource": "db",
"public": false,
"options": {
"strictObjectIDCoercion": true
}
},
"Role": {
"dataSource": "db",
"public": false
},
"Test": {
"dataSource": "mongoDS",
"public": true
}
}
test.js
'use strict';
module.exports = function(Test) {
Test.create({
"first_name":"akhil"
},function(data){
console.log(data);
})
};
test.json
{
"name": "Test",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"first_name": {
"type": "string"
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
Your help will be highly appreciated
Bug or feature request
Description of feature (or steps to reproduce if bug)
Link to sample repo to reproduce issue (if bug)
Expected result
Actual result (if bug)
Additional information (Node.js version, LoopBack version, etc)
I am getting error: Error: Cannot call Test.create(). The create method has not been setup The PersistedModel has not been correctly attached to a datasource.
Here is my datasource.json:
model-config.json:
test.js
test.json
Your help will be highly appreciated
Bug or feature request
Description of feature (or steps to reproduce if bug)
Link to sample repo to reproduce issue (if bug)
Expected result
Actual result (if bug)
Additional information (Node.js version, LoopBack version, etc)