loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Question about mongodb native method

Open Spark-star opened this issue 12 years ago • 4 comments

How can I use others mongodb native method(i.e $exists, $elementMatch) expect the operators the document mentioned ( like, nlike, gt, lt and so on)?

In forum , I found someone use mongo native method to realize it , and I tried it , but it doesn't match the demand.

For example: If I want find something that have one property exists, and need some related model property, How can I do?

Post.find(
  {where: { exists: {title: true}}, include: author },
  function(err, function(err, posts){ console.log(posts); });

I think this could be work , but it doesn't .

I found in dao.js( line 597), the code:

  // Coerce the array items
     if (Array.isArray(val)) {
       for (var i = 0; i < val.length; i++) {
         if (val[i] !== null && val[i] !== undefined) {
           val[i] = DataType(val[i]);
         }
       }
     } else {
       if (val !== null && val !== undefined) {
         val = DataType(val);
       }
     } 

which change the value not in "operators" to [object Object],so the mongodb engine receive the "query" [object Object] which is not i want.

Is it a bug?

Spark-star avatar Oct 15 '14 10:10 Spark-star

+1

leoliew avatar Nov 19 '14 16:11 leoliew

Does this bug get fixed now? I occurs the same problem :(

If the issue is still open, the bug is not fixed.

superkhau avatar Sep 02 '15 22:09 superkhau

@raymondfeng ^

superkhau avatar Sep 21 '15 20:09 superkhau

Closing in favour of https://github.com/strongloop/loopback-datasource-juggler/pull/1180

bajtos avatar Dec 08 '16 08:12 bajtos