-2

Lets say i have object like this:

var a = {
    b: {
        c: 1,
        d: 2
    }
}

And i have saved this object in Parse backend. There are 100 objects, but with different c and d values. Can i do search searching only objects which contains d:2. Or the only way is to query all objects and then use for loop which will search for d:2?

Dont read this! Writting this line just to get posted, because system does not allow to post me question, dont know why

Thank you

Update

Maybe i am not clear enough, I am using parse.com you can retrieve objects by using this line:

var GameScore = Parse.Object.extend("GameScore");
var query = new Parse.Query(GameScore);
query.equalTo("playerName", "Dan Stemkoski");
query.find();

If anybody knows if you can retrieve objects with specific values in nested objects, that would be great.

rici
  • 234,347
  • 28
  • 237
  • 341
Lukas Junokas
  • 91
  • 1
  • 9

1 Answers1

0

You can do something like this

var a = {
         b0: {
              c: 1,
              d: 2
             },
         b1: {
              c: 5,
              d: 3
             },
         b2: {
              c: 1,
              d: 4
             },
         b3: {
              c: 2,
              d: 2
             },
         b4: {
              c: 1,
              d: 4
             },
         b5: {
              c: 7,
              d: 2
             },
        },
 d2s = Object.keys(a).filter(e => a[e].d == 2).map(e => a[e]);

document.write("<pre>" + JSON.stringify(d2s,null,2) + "</pre>");
Redu
  • 25,060
  • 6
  • 56
  • 76