node-orm2 icon indicating copy to clipboard operation
node-orm2 copied to clipboard

MantoToOne as key

Open olee opened this issue 9 years ago • 1 comments

Hi, I want to create a schema with a many-to-one association to be part of the key: I have two entities user and node. Node should use a combination of the user it belongs to + a start time as key:

User [id] 
Node [user_id, start]

I tried adding key: true when registering the association, but it had not effect and even after looking into the source code I could not find anything like that. Is this not possible yet with this library?

olee avatar Jun 04 '16 20:06 olee

Composite keys might work. Not sure if the key syntax supports it though; You may need to pass an option like id: [user_id, start] but I've never tried it.

dxg avatar Jun 06 '16 00:06 dxg