Database.query (Query) return type is not an array?

While working on the Skygear JS SDK, the query query returns an array?

  readDummy: function(){
        const Test = skygear.Record.extend('test_test');
        const Query = new skygear.Query(Test);

        skygear.publicDB.query(Query).then((records) => {
          console.log(records.constructor === Array); // return false
          console.log(JSON.stringify(records[0])); //do display correctly
          //{"_id":"test_test/b9633d1a-ff3c-491b-82f3-93c8cefb5313","_access":[{"public":true,"level":"read"}],"content":"Hello World"}
        }, (error) => {
          console.error(error);
        });

      },

      

+3


source to share


1 answer


An object actually appears QueryResult

, which expands Array

.

Anything you pass to an object seems too special in terms of the exact type.

You can try this



Array.from(records)

      

to make it a native array.

+3


source







All Articles