I'm trying to use pub/sub methods and I get spammed with this error:
error: Must specify an `id` when calling `Model.room(id)`
My Model looks like this:
module.exports = {
tableName: 'accounts',
autoPk: false,
attributes: {
'id': {
type: 'INTEGER',
primaryKey: true,
columnName: 'id'
},
'alias': {
type: 'STRING',
required: true
}
};
and then my controller method:
'subscribe': function(req, res) {
Account.find({'select': ['steam_id', 'online']})
.then(function(users) {
Account.subscribe(req.socket, users);
})
.catch(function(err) {
console.log(err);
});
}
and finally, my client-side js subscribe:
socket.on('connect', function connectedToSockets() {
console.log('Subscribing');
socket.get('/friends/subscribe');
socket.get('/user/subscribe');
});
I cannot for the life of me, figure out why I am getting literally spammed by this error, all the fixes say to set a PrimaryKey on a column,
I'm using sails-mysql
adapter
Thanks!
So to anybody that has this problem, I figured it out:
I wasn't returning the ID from the query under subscribing, so when I added ID as well the error goes away, I guess it just need the ID for some reference.
This fixed it, adding id