Re: Is it possible to have a where{} or include:{} inside the associations.options

40 views
Skip to first unread message

Mick Hansen

unread,
Apr 28, 2015, 2:30:34 AM4/28/15
to kiwi, sequ...@googlegroups.com
Something like it is possible using:

db.hasOne(model, {scope: {key: value}});

The scope will be applied to all association getters, includes and creators.
Although im not entirely certain its implemented for hasOne (i know it is for belongsTo, belongsToMany and hasMany though)

On Tue, Apr 28, 2015 at 12:34 AM, kiwi <kare...@adcolony.com> wrote:
Will this work?

db.hasOne(model, options:{foreignKey: 'fk', where:{ model.someKey=someValue}}

Because I basically have a table with a composite PK, so these fields are "table_name" and "table_id"
The table_name references diff tables, so the table_id can have overlap, and when I try to use it correctly
I don't know which table to target...if sequelize offers some sort of composite foreign key it would
help me a lot for now I want something more like above to set up my association :

db.hasOne(model, options:{foreignKey: 'table_id', where:{ model.table_name=someTableName}}

 






--
Mick Hansen
@mhansendev
mhansen.io
Reply all
Reply to author
Forward
0 new messages