0

I am developing a sails.js app with MySQL. I have a model, for which create and retrieve work without any problems.

 Model.findOne({ where: { someAttribute : 'foo' }, function(err, model) {
  // some logic
});

works fine, but not

Model.find({ where: { someAttribute : 'foo' }, function(err, model) {
  // some logic
});

Model.find(...) always returns an empty array. I have multiple records on the model which satisfy the where clause condition.

Travis Webb
  • 14,688
  • 7
  • 55
  • 109
Jaseem Abbas
  • 5,028
  • 6
  • 48
  • 73
  • 1
    It should work as expected. I would re-check or post more specific code. – Meeker Apr 25 '15 at 18:07
  • 2
    This isn't even valid Javascript syntax: `find({ where: { someAttribute : 'foo' }, function` so you're obviously not posting your exact code. – Travis Webb Apr 25 '15 at 21:22

1 Answers1

1

Given code should cause error! It is not even in valid format. It should be

Model.findOne({ where: { someAttribute : 'foo' }}).exec(function(err, model) {
    // some logic
});

Model.find({ where: { someAttribute : 'foo' }}).exec(function(err, model) {
    // some logic
});

Update your code to clarify your question.

hasan3050
  • 195
  • 2
  • 10