How to use the 'via' attribute in a collection with more than one PK? Below is an example of a hasMany datamodel.
The Model Definition.
Persistence.prototype.collections.Device = Waterline.Collection.extend({
identity: 'device',
connection: 'default',
attributes: {
name: {
type: 'string',
required: true,
primaryKey: true
},
uuid:{
type: 'string',
required: true,
primaryKey: true
},
dataItems: {
collection: 'dataitem',
via: 'id'
}
}
});
The Collection Definition with the two 'via' attributes.
Persistence.prototype.collections.DataItem = Waterline.Collection.extend({
identity: 'dataitem',
connection: 'default',
attributes: {
id: {
type: 'string',
unique: true,
primaryKey: true
},
category: 'string',
type: 'string',
from_device: {
model: 'device'
via: 'name', // ??????
via: 'uuid' // ?????????
}
}
});