Posted by & filed under LoopbackJS.

I was trying to post to a model in the Loopback Explorer and certain fields referenced IDs from related models, only no matter what format my JSON was in my data was being inserted as an array where each index value corresponded to each letter in the string of text. I discovered that the cause of this was because my relationships weren’t setup correctly. In my case the “model” value in my relationship declaration in my model’s model.json config file wasn’t respecting the proper case sensitivity of the model.

When relationships are correctly established, the model schema displayed in the Explorer will show that the input type is “objectid” rather than simply “object”. With the input type set as “objectid”, you simply have to provide the ID of the related model entry, rather than ObjectId("[id-string]").

Hopefully this makes sense to somebody other than me :)