I have Users, Notifications, and a NotificationsUsers table (automatically generated by sequelize associations). I'm able to get all notifications to a user but I'd like to store a 'read' field (TRUE or FALSE value) in the association table. So far this has all been setup but I'm unable to pull the 'read' field from the association table.
My Code-
Usr.getNotifications({where: ['Notifications.createdAt >= ?', datetime], joinTableAttributes: ['read']}).success(function(notes) {
defer.resolve(notes);
});
Which runs this query-
SELECT `Notifications`.*, `NotificationsUsers`.`read` as `NotificationsUser.read` FROM `Notifications`, `NotificationsUsers` WHERE `NotificationsUsers`.`UserId` = 1 AND `NotificationsUsers`.`NotificationId` = `Notifications`.`id` AND Notifications.createdAt >= '0000-00-00 00:00:00';
What I get back are just the Notifications table fields. An example of one of the results I get back-
{ dataValues:
{ id: 7,
type: 'Warranty',
title: 'Warranty Request From Jim Bob',
text: 'My sink is drippy. I don\'t like drippy sinks.' },
_previousDataValues:
{ id: undefined,
type: undefined,
title: undefined,
text: undefined },
__options:
{ timestamps: true,
createdAt: 'createdAt',
updatedAt: 'updatedAt',
deletedAt: 'deletedAt',
instanceMethods: {},
classMethods: {},
validate: {},
freezeTableName: false,
underscored: false,
syncOnAssociation: true,
paranoid: false,
whereCollection: [Object],
schema: null,
schemaDelimiter: '',
language: 'en',
defaultScope: null,
scopes: null,
hooks: [Object],
omitNull: false,
uniqueKeys: {},
hasPrimaryKeys: false },
options: { isNewRecord: false, isDirty: false },
hasPrimaryKeys: false,
selectedValues:
{ id: 7,
type: 'Warranty',
title: 'Warranty Request From Jim Bob',
text: 'My sink is drippy. I don\'t like drippy sinks.',
createdAt: Fri Sep 05 2014 11:18:40 GMT-0500 (CDT),
updatedAt: Fri Sep 05 2014 11:18:40 GMT-0500 (CDT) },
__eagerlyLoadedAssociations: [],
isNewRecord: false,
NotificationsUser:
{ dataValues: [Object],
_previousDataValues: [Object],
__options: [Object],
options: [Object],
hasPrimaryKeys: true,
selectedValues: [Object],
__eagerlyLoadedAssociations: [],
isNewRecord: false } }
Given the information any suggestions what I may be doing wrong? Why can't I I get the NotificationsUsers.read field?