Phan Phan - 1 year ago 116
Javascript Question

Loopback embedsMany Helper methods don't work

I have these two models:


"name": "student",
"plural": "students",
"base": "User",
"idInjection": false,
"options": {
"validateUpsert": true
"relations": {
"test": {
"type": "embedsMany",
"model": "test",
"property": "mytest",
"options": {
"validate": true,
"forceId": false



"name": "test",
"base": "Model",
"idInjection": true,
"options": {
"validateUpsert": true
"properties": {
"text": {
"type": "string",
"required": true

When I try to create a new test I get this error

Error: Invalid reference: undefined

I create the test in this way:


studentInstance.test.add({text : "something "})

What am I doing wrong?

Answer Source

You don't have test model.

In test.json you defined its names as notification => "name": "notification",


For building (without persisting) an embedded instance please use{text : "something "})

and for creating (with persisting) that please use studentInstance.test.create({text : "something "})

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download