0.0.5 • Published 7 years ago

parse-query-util v0.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Parse Query Util

Provides utility functions for large parse queries (i.e. with more than 1000 results).

Installation

npm install --save-dev parse-query-util

Usage

In typescript (javascript is similar):

import { getAllObjects, foldAllObjects } from "parse-query-util";

const query = new Parse.Query("Car")
    .equalTo("owner", "David Beckham");

getAllObjects(query, { useMasterKey: true }).then(cars => {
    // do smth with all cars
});

countAllObjects(query, { useMasterKey: true }).then(numberOfCars => {
    // do smth with total number
})

// this one iterates block-wise over all cars.
// Thus, we do not need to keep all of them in memory.
foldAllObjects(query,
    {},
    (akku, cars) => {
        for (car of cars) {
            const c = car.get("color");
            akku[c] = (akku[c] || 0) + 1;
        }
    },
    { sessionToken: "blah" }).then(allColorsOfMyCars => {
        // do smth with that number
    });

Test

npm test
0.0.5

7 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago