Loopback - EmbedsOne relation producing error

Viewed 462

I have following two models

Nurse

Room

A room has belongsTo relation with the nurse model as defined below:

"relations": {
        "nurse": {
            "model": "Nurse",
            "type": "belongsTo",
            "foreignKey": "nid"
        }
    }

which works fine and produces the data on following urls

http://localhost:3000/api/Rooms/1

http://localhost:3000/api/Rooms/1/nurse

but when I try the embedsOne relation as defined below:

"relations": {
        "nurse": {
            "model": "Nurse",
            "type": "embedsOne",
            "foreignKey": "nid"
        }
    }

and try accessing url at

http://localhost:3000/api/Rooms/1

I get the following error:

message: "ER_BAD_FIELD_ERROR: Unknown column '_nurse' in 'field list'",

thoughts?

1 Answers
Related