ShinGecko / neKo-Api

Api provided to support the innovative chat neKo
ISC License
0 stars 1 forks source link

Relation Chat.belongsTo(User) #7

Open Shenrak opened 7 years ago

Shenrak commented 7 years ago

@justinrlle I have a bug generated by your code in model relations

Chat.belongsTo(User, 'user', 'private.idUser1', 'id')
Chat.belongsTo(User, 'user', 'private.idUser2', 'id')

Gives me an error Error: The field 'user' is already used by another relation. That is quite new as i created index.js in app/models.

I'm surprised that that code worked before actually. Any idea ?

justinrlle commented 7 years ago

To be frank... I didn't test that code. It was just to have the logic somewhere in the code. Just change the code to:

Chat.belongsTo(User, 'user1', 'private.idUser1', 'id')
Chat.belongsTo(User, 'user2', 'private.idUser2', 'id')

And it should work

Shenrak commented 7 years ago

What is exactly the purpose to that code ? Make private chats between two users ?

justinrlle commented 7 years ago

Yup, that's it. I tried to do some kind of subclassing straight from the model, but it might not be a good workaround...