We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have created my model like this
const SequelizeMock = require('sequelize-mock');\n const DBConnectionMock = new SequelizeMock(); const SiteTag = DBConnectionMock.define('SiteTag',{ instanceMethods: { getSiteId: function () { return this.get('siteId'); }, getTag: function () { return this.get('tag'); }, }, }); SiteTag.$queueResult([ SiteTag.build({ siteId: 1, tag: 'First tag', }), SiteTag.build({ siteId: 2, tag: 'Second tag', }), ]); module.exports.SiteTag = SiteTag;
And later I want to delete the instance with the siteId 2. I have written this code
siteId
2
const destroyed = await SiteTag.destroy({where: {siteId: input.id}});
and this is what destroyed contains:
destroyed
[ fakeModelInstance { options: { timestamps: true, paranoid: undefined, createdAt: undefined, updatedAt: undefined, deletedAt: undefined, isNewRecord: true }, _values: { instanceMethods: [Object], siteId: 1, tag: 'First tag', id: 1, createdAt: 2020-01-09T11:08:06.128Z, updatedAt: 2020-01-09T11:08:06.128Z }, dataValues: { instanceMethods: [Object], siteId: 1, tag: 'First tag', id: 1, createdAt: 2020-01-09T11:08:06.128Z, updatedAt: 2020-01-09T11:08:06.128Z }, hasPrimaryKeys: true, __validationErrors: [] }, fakeModelInstance { options: { timestamps: true, paranoid: undefined, createdAt: undefined, updatedAt: undefined, deletedAt: undefined, isNewRecord: true }, _values: { instanceMethods: [Object], siteId: 2, tag: 'Second tag', id: 2, createdAt: 2020-01-09T11:08:06.128Z, updatedAt: 2020-01-09T11:08:06.128Z }, dataValues: { instanceMethods: [Object], siteId: 2, tag: 'Second tag', id: 2, createdAt: 2020-01-09T11:08:06.128Z, updatedAt: 2020-01-09T11:08:06.128Z }, hasPrimaryKeys: true, __validationErrors: [] } ]
I am still getting the instance with siteId 2... can someone please explain to me what I am doing wrong?
I am getting the same result when I use SiteTag.findOne({where: {siteId: input.id}});
SiteTag.findOne({where: {siteId: input.id}});
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have created my model like this
const SequelizeMock = require('sequelize-mock');\n const DBConnectionMock = new SequelizeMock(); const SiteTag = DBConnectionMock.define('SiteTag',{ instanceMethods: { getSiteId: function () { return this.get('siteId'); }, getTag: function () { return this.get('tag'); }, }, }); SiteTag.$queueResult([ SiteTag.build({ siteId: 1, tag: 'First tag', }), SiteTag.build({ siteId: 2, tag: 'Second tag', }), ]); module.exports.SiteTag = SiteTag;
And later I want to delete the instance with the
siteId
2
. I have written this codeconst destroyed = await SiteTag.destroy({where: {siteId: input.id}});
and this is what
destroyed
contains:[ fakeModelInstance { options: { timestamps: true, paranoid: undefined, createdAt: undefined, updatedAt: undefined, deletedAt: undefined, isNewRecord: true }, _values: { instanceMethods: [Object], siteId: 1, tag: 'First tag', id: 1, createdAt: 2020-01-09T11:08:06.128Z, updatedAt: 2020-01-09T11:08:06.128Z }, dataValues: { instanceMethods: [Object], siteId: 1, tag: 'First tag', id: 1, createdAt: 2020-01-09T11:08:06.128Z, updatedAt: 2020-01-09T11:08:06.128Z }, hasPrimaryKeys: true, __validationErrors: [] }, fakeModelInstance { options: { timestamps: true, paranoid: undefined, createdAt: undefined, updatedAt: undefined, deletedAt: undefined, isNewRecord: true }, _values: { instanceMethods: [Object], siteId: 2, tag: 'Second tag', id: 2, createdAt: 2020-01-09T11:08:06.128Z, updatedAt: 2020-01-09T11:08:06.128Z }, dataValues: { instanceMethods: [Object], siteId: 2, tag: 'Second tag', id: 2, createdAt: 2020-01-09T11:08:06.128Z, updatedAt: 2020-01-09T11:08:06.128Z }, hasPrimaryKeys: true, __validationErrors: [] } ]
I am still getting the instance with
siteId
2... can someone please explain to me what I am doing wrong?I am getting the same result when I use
SiteTag.findOne({where: {siteId: input.id}});
The text was updated successfully, but these errors were encountered: