BlinkUX/sequelize-mock

$autoQueryFallback isn't work

Closed this issue · 1 comments

I created my model such this:
var domainMock = dbMock.define('domains',{
'domain':simpletest.com',
},{
'$autoQueryFallback':false
});

So when i try to search domainMock.findOne({domain:"anotherdomain.com"}), instance create a new record

Or I wrote a wrong code?

When I run your code (as follows), I get the following:

var domainMock = dbMock.define('domains', {
  'domain':'simpletest.com',
}, {
});

domainMock.findOne({domain:"anotherdomain.com"}).then(function (domain) {
  console.log(domain); // Logs Mock Domain with `anotherdomain.com`
});

If you want to turn off the autoQueryFallback functionality, you actually want the option without the $ before it. So something like the following should work.

var domainMock = dbMock.define('domains', {
  'domain':'simpletest.com',
}, {
  'autoQueryFallback': false
});

domainMock.findOne({domain:"anotherdomain.com"}); // Will throw SequelizeMockEmptyQueryQueueError

You can check out more information about the configuration on the query page, If that doesn't answer your question let me know and I can try and help further.