To dynamically set the table name based on the device ID in LoopBack 4.
In loopback 4 , need to create separate table for each user , i.e table name with their device id . eg: motor_log_device_id
Need to pass table name dynamically from device.controller.ts. Need help with that.
My model.ts file
// Model definition without dynamic table name
@model()
export class MotorStatus extends Entity {
@property({
description: 'Motor log ID',
type: 'number',
id: true,
generated: true,
index: true,
})
id: number;
@property({
description: 'Motor packet sync at',
type: 'date',
required: true,
index: true,
})
created_at: string;
}
const SETTING = {
settings: {
postgresql: {
schema: 'public',
table: 'dbtablename'
}
}
}
@model(SETTING)
export class MotorStatus extends Entity {
@property({
description: 'Motor log ID',
type: 'number',
id: true,
generated: true,
index: true,
})
id: number;
@property({
description: 'Motor packet sync at',
type: 'date',
required: true,
index: true,
})
created_at: string;
}
Is there any way to pass table name dynamically to SETTING and set to model decorator.