LoopBack is an open source Node.js framework built on top of Express optimized for mobile, web, and other devices. Connect to multiple data sources, write business logic in Node.js, glue on top of your existing services and data, connect using JS, iOS & Android SDKs.
bajtos on add-node10
hi, i was working my way through the LB4 tutorial and got stuck when this error started getting thrown when running npm run build
/ npm run migrate
Migrating schemas (alter existing schema)
Cannot migrate database schema Error: Cannot migrate models not attached to this datasource: TodoList Todo TodoListImage Note
at /Users/~/~/code/~/api-test/node_modules/loopback-datasource-juggler/lib/datasource.js:1146:12
Tried reverting to earlier commits, destroying the db, etc but to no avail - any ideas?
var app = require('../../server/server');
console.log(app.models.Book);
it gives me undefined.
Hi everyone,
I am working on creating dynamic models and repositories in lb4. I came across this issue:
'BookModel' refers to a value, but is being used as a type here. Did you mean 'typeof BookModel'. in
'''
const DynamicRepositoryClass = defineCrudRepositoryClass<
BookModel, // issue is here
typeof BookModel.prototype.id,
{}
>(BookModel);
'''
But if typeof is used I get an error as follows:
Type 'DynamicModelCtor<typeof Entity, { id: number; title?: string | undefined; }>' does not satisfy the constraint 'Entity'.
I used the Model definitions as given in the documentation https://loopback.io/doc/en/lb4/Dynamic-models-repositories-controllers.html#defining-a-datasource
'''
const bookDef = new ModelDefinition({
name: 'book',
properties: {
....
},
},
title: {
},
settings: {
idInjection: false,
mysql: {schema: 'test', table: 'BookStore'},
},
});
const BookModel = defineModelClass<typeof Entity, {id: number; title?: string}>(
Entity,
bookDef,
);
'''
Please help.
POST /api/Customers
with some irrelevant json data...