{"name": "user", "options": { "base": "User", "relations": { "accessTokens": { "model": "accessToken", "type": "hasMany", "foreignKey": "userId" }, "inventories": { "model": "Inventory", "type": "hasMany", "foreignKey": "userId" } },
...
...{"name": "Inventory","options": { "idInjection": false, "postgresql": { "schema": "public", "table": "inventory" }, "relations": { "user": { "model": "user", "type": "belongsTo", "foreignKey": "userId" } } }
...
...Inventory.belongsTo('user', {model: User, foreignKey: 'userId'});User.hasMany('inventories', {model: Inventory, foreignKey: 'userId'});
User.create({firstName: 'John', email: 'f...@bar.com', password: 'password'}, function(err, user){
user.inventories.create({id: 'id1', available: 31, locationId: 'blah'}, function(err, inv){ console.log('inventory is ' + inv); }});
error: column "userid" of relation "inventory" does not exist
"Relation \"inventories\" is not defined for user model"
Shared class \"user\" has no method handling GET /1/inventories
--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
var config = require('./inventory.json');var app = require('../app');var db = app.dataSources.db;
var Inventory = module.exports = db.createModel( 'inventory', config.properties, config.options);
app.model(Inventory);Inventory.belongsTo('user', {model: User, foreignKey: 'userId'});User.hasMany('inventories', {model: Inventory, foreignKey: 'userId'});
dataSource.automigrate('inventory', function(err){
});
dataSource.automigrate('user', function(err){ User.create({firstName: 'John', email: 'f...@bar.com', password: 'password'}, function(err, user){ user.inventories.create({id: 'id2', available: 31, locationId: 'blarg'}, function(err, inv){
console.log('inventory is ' + inv); }); });});GET to /users?filter[include][inventories])
"Relation \"inventories\" is not defined for user model"