I have looked at a lot of old SO questions which have broken GitHub links and SailsJS Trello, however I am still unclear.
Is it possible, to populate a field (one-to-one relationship) in SailsJS and return only specific fields (either via select or omit).
await Document.find({id: id}).populate('createdBy', {select: ['name']})
I am getting
UsageError: Invalid populate(s).
Details:
Could not populate `createdBy` because of ambiguous usage. This is a singular ("model") association, which means it never refers to more than _one_ associated record. So passing in subcriteria (i.e. as the second argument to `.populate()`) is not supported for this association
, since it generally wouldn't make any sense. But that's the trouble-- it looks like some sort of a subcriteria (or something) _was_ provided!
(Note that subcriterias consisting ONLY of `omit` or `select` are a special case that _does_ make sense. This usage will be supported in a future version of Waterline.)
Here's what was passed in:
{ select: [ 'name' ] }
In models,
createdBy: {
model: 'user',
description: 'Who is this document assigned to'
},
I am using sails 1.1.0, waterline 0.13.5-0
Am I doing this right? Is there a way to do this?