Я посмотрел много старых вопросов SO, которые сломали ссылки на GitHub и SailsJS Trello, однако мне все еще неясно.
Возможно ли заполнить поле (отношение один к одному)в SailsJS и возвращать только определенные поля (либо через select, либо через опустить).
await Document.find({id: id}).populate('createdBy', {select: ['name']})
Я получаю
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' ] }
В моделях
createdBy: {
model: 'user',
description: 'Who is this document assigned to'
},
Я являюсьс помощью паруса 1.1.0
, ватерлинии 0.13.5-0
Я правильно делаю?Есть ли способ сделать это?