ReactJS
Data objects
Query cookbook
22 min
react query cookbook for parse introduction we’ve already seen how a parse query parse query with get get can retrieve a single parse object parse object from back4app there are many other ways to retrieve data with parse query parse query you can retrieve many objects at once, use conditions on the objects you wish to retrieve, and more in this guide, you will ding deep into the parse query parse query class and see all the methods you can use to build your queries you will use a simple database class with some mocked data to perform the queries using the javascript console on back4app prerequisites to complete this tutorial, you will need an app created on back4app goal explore the parse query parse query class different methods the parse query class any query operation on parse uses the parse query parse query object type, which will help you retrieve specific data from your back4app throughout your app to create a new parse query parse query , you need to pass as a parameter the desired parse object parse object subclass, which is the one that will contain your query results it is crucial to know that a parse query parse query will only resolve after calling a retrieve method (like parse query find parse query find or parse query get parse query get ), so a query can be set up and several modifiers can be chained before actually being called you can read more about the parse query parse query class here at the official documentation https //parseplatform org/parse sdk js/api/master/parse query html using the js console on back4app inside your back4app application’s dashboard, you will find a very useful api console in which you can run javascript code directly in this guide you will use to store and query data objects from back4app on your app main dashboard go to core >api console >js console core >api console >js console save your data objects to run the queries on this guide you’ll need first to populate your app with some data let’s create a sample class called profile profile , which mocks a social media profile class using famous people names and the following fields string type name name ; date type birthday birthday ; number (integer) type friendcount friendcount ; array (string array) type favoritefoods favoritefoods ; array (number array) type luckynumbers luckynumbers ; geopoint type lastloginlocation lastloginlocation ; nullable pointer type premiummembership premiummembership , related to a membership membership class containing string name name and date expirationdate expirationdate fields here is the parse object parse object classes creation code, so go ahead and run it in your api console 1 // add profile objects and create table 2 // adam sandler 3 let profile = new parse object('profile'); 4 profile set('name', 'adam sandler'); 5 profile set('birthday', new date('09/09/1966')); 6 profile set('friendcount', 2); 7 profile set('favoritefoods', \['lobster', 'bread']); 8 profile set('luckynumbers', \[2, 7]); 9 profile set('lastloginlocation', new parse geopoint(37 38412167489413, 122 01268034622319)); 10 await profile save(); 11	 12 // britney spears 13 profile = new parse object('profile'); 14 profile set('name', 'britney spears'); 15 profile set('birthday', new date('12/02/1981')); 16 profile set('friendcount', 52); 17 profile set('favoritefoods', \['cake', 'bread']); 18 profile set('luckynumbers', \[22, 7]); 19 profile set('lastloginlocation', new parse geopoint(37 38412167489413, 122 01268034622319)); 20 await profile save(); 21	 22 // carson kressley 23 profile = new parse object('profile'); 24 profile set('name', 'carson kressley'); 25 profile set('birthday', new date('11/11/1969')); 26 profile set('friendcount', 12); 27 profile set('favoritefoods', \['fish', 'cookies']); 28 profile set('luckynumbers', \[8, 2]); 29 profile set('lastloginlocation', new parse geopoint(37 38412167489413, 122 01268034622319)); 30 await profile save(); 31	 32 // dan aykroyd 33 // creates related object membership for this user only 34 let membership = new parse object('membership'); 35 membership set('name', 'premium'); 36 membership set('expirationdate', new date('10/10/2030')) 37 await membership save(); 38 profile = new parse object('profile'); 39 profile set('name', 'dan aykroyd'); 40 profile set('birthday', new date('07/01/1952')); 41 profile set('friendcount', 66); 42 profile set('favoritefoods', \['jam', 'peanut butter']); 43 profile set('luckynumbers', \[22, 77]); 44 profile set('lastloginlocation', new parse geopoint(37 38412167489413, 122 01268034622319)); 45 profile set('premiummembership', membership); 46 await profile save(); 47	 48 // eddie murphy 49 profile = new parse object('profile'); 50 profile set('name', 'eddie murphy'); 51 profile set('birthday', new date('04/03/1961')); 52 profile set('friendcount', 49); 53 profile set('favoritefoods', \['lettuce', 'pepper']); 54 profile set('luckynumbers', \[6, 5]); 55 profile set('lastloginlocation', new parse geopoint( 27 104919974838154, 52 61428045237739)); 56 await profile save(); 57	 58 // fergie 59 profile = new parse object('profile'); 60 profile set('name', 'fergie'); 61 profile set('birthday', new date('03/27/1975')); 62 profile set('friendcount', 55); 63 profile set('favoritefoods', \['lobster', 'shrimp']); 64 profile set('luckynumbers', \[13, 7]); 65 profile set('lastloginlocation', new parse geopoint( 27 104919974838154, 52 61428045237739)); 66 await profile save(); 67	 68 console log('success!'); after running this code, you should now have a profile profile class in your database with six objects created your new class should look like this let’s now take a look at examples from every parse query parse query method, along with brief explanations on what they do please note that some methods in this list can take options options as an additional argument, but in most cases, it is only related to masterkey masterkey usage and not relevant to this guide content, so this possibility will be omitted whenever not relevant query retrievers these methods are responsible for running the query and retrieving its results, being always present in your query implementation cancel // cancels the current network request 1 let query = new parse query('profile'); 2 let queryresult = await query find(); 3 // this is hard to test in small databases, since by the time 4 // "cancel" is called, the "find" request is already resolved 5 queryresult = query cancel(); 6 console log(queryresult); count // retrieves the count of parse object results that meet the query criteria 1 let query = new parse query('profile'); 2 let queryresult = await query count(); 3 console log(queryresult); distinct // runs the query and returns a list of unique values from the results and the specified key 1 let query = new parse query('profile'); 2 let queryresult = await query distinct('favoritefoods'); 3 console log(queryresult); find // this is the basic method for retrieving your query results, always returning an array of parse object instances, being empty when none are found 1 let query = new parse query('profile'); 2 // when using find() in a query without other operations, you will 3 // get every object saved in your class 4 let queryresult = await query find(); 5 console log(queryresult); findall // retrieves a complete list of parse objects that satisfy this query 1 let query = new parse query('profile'); 2 // when using findall() in a query without other operations, you will 3 // get every object saved in your class 4 let queryresult = await query findall(); 5 console log(queryresult); first // retrieves the first parse object instance that meets the query criteria 1 let query = new parse query('profile'); 2 // pay attention to your query ordering when using first 3 let queryresult = await query first(); 4 console log(queryresult); get // this quick method is used to retrieve a single parse object instance when you know its objectid 1 let query = new parse query('profile'); 2 // since objectid is randomly set in your database, make sure to inform a 3 // valid one when testing this method 4 let queryresult = await query get('c6endlnfdq'); 5 console log(queryresult); 	 query conditioners these methods give you the possibility of applying conditional constraints to your query, which are arguably the most important operations in querying remember that these operations can all be chained before the results are retrieved, so many combinations can be achieved to solve your querying needs addcondition // helper that is called by parse for filtering objects using conditional constants, such as “$gt”, “$eq” and so on only usable by users in very specific cases 1 let query = new parse query('profile'); 2 query addcondition('friendcount', '$gt', 25); 3 let queryresult = await query find(); 4 console log(queryresult); regexstartwith // helper used by parse that converts string for regular expression at the beginning 1 let query = new parse query('profile'); 1 let query = new parse query('profile'); 2 let result = query regexstartwith('text'); 3 console log(result); containedby // filters objects in which a key value must be contained by the provided array of values get objects where all array elements match 1 let query = new parse query('profile'); 2 query containedby('luckynumbers', \[2, 7]); 3 let queryresult = await query find(); 4 console log(queryresult); containedin // filters objects in which a key value is contained in the provided array of values 1 let query = new parse query('profile'); 2 // containedin can be used on any data type such as numbers and strings 3 query containedin('luckynumbers', \[2, 7]); 4 let queryresult = await query find(); 5 console log(queryresult); contains // filters objects in which a string key value contains the provided text value be aware that this condition is case sensitive 1 let query = new parse query('profile'); 2 // this can be slow in large databases and are case sensitive 3 query contains('name', 'da'); 4 let queryresult = await query find(); 5 console log(queryresult); containsall // filters objects in which an array type key value must contain every value provided 1 let query = new parse query('profile'); 2 query containsall('luckynumbers', \[2, 7]); 3 let queryresult = await query find(); 4 console log(queryresult); containsallstartingwith // filters objects in which an array type key value must contain every string value provided 1 let query = new parse query('profile'); 2 // these should be string values 3 query containsallstartingwith('favoritefoods', \['shrimp', 'lobster']); 4 let queryresult = await query find(); 5 console log(queryresult); doesnotexist // filters objects in which a key value is not set 1 let query = new parse query('profile'); 2 query doesnotexist('premiummembership'); 3 let queryresult = await query find(); 4 console log(queryresult); doesnotmatchkeyinquery // requires that a key’s value does not match a value in an object returned by a different parse query useful for multi object querying 1 let query = new parse query('profile'); 2 // multiple queries can be combined using this, useful when there are more objects 3 // related, not our example case 4 query doesnotmatchkeyinquery('friendcount', 'friendcount', new parse query('profile') lessthan('friendcount', 50)); 5 query greaterthan('friendcount', 10); 6 let queryresult = await query find(); 7 console log(queryresult); doesnotmatchquery // requires that an object contained in the given key does not match another query useful for multi object querying 1 let innerquery = new parse query('membership'); 2 innerquery greaterthan('expirationdate', new date()); 3 let query = new parse query('profile'); 4 query exists('premiummembership'); 5 query doesnotmatchquery('premiummembership', innerquery); 6 let queryresult = await query find(); 7 console log(queryresult); endswith // filters objects in which a string key’s value ends with the provided text value 1 let query = new parse query('profile'); 2 // this is faster than other string searches by using backend index 3 query endswith('name', 'ie'); 4 let queryresult = await query find(); 5 console log(queryresult); equalto // filters objects in which a specific key’s value is equal to the provided value 1 let query = new parse query('profile'); 2 // equalto can be used in any data type 3 query equalto('friendcount', 2); 4 let queryresult = await query find(); 5 console log(queryresult); exists // filters objects in which a key value is set 1 let query = new parse query('profile'); 2 query exists('premiummembership'); 3 let queryresult = await query find(); 4 console log(queryresult); fulltext // filters objects in which a string key’s value wrap matches the provided text value in it it can have many customizable options to improve its results, like language specification and score order check the parse docs to have a complete understanding of that 1 let query = new parse query('profile'); 2 // fulltext can be very powerful in text search queries, but 3 // also slow in large datasets when its options are not optimized 4 query fulltext('name', 'spears', { diacriticsensitive false, casesensitive false }); 5 // in order to sort you must use select and ascending ($score is required) 6 query ascending('$score'); 7 query select('$score'); 8 let queryresult = await query find(); 9 console log(queryresult); greaterthan // filters objects in which a specific key’s value is greater than the provided value 1 let query = new parse query('profile'); 2 // greaterthan can be used on numbers and dates 3 query greaterthan('birthday', new date('08/19/1980')); 4 let queryresult = await query find(); 5 console log(queryresult); greaterthanorequalto // filters objects in which a specific key’s value is greater than or equal to the provided value 1 let query = new parse query('profile'); 2 // greaterthanorequalto can be used on numbers and dates 3 query greaterthanorequalto('friendcount', 49); 4 let queryresult = await query find(); 5 console log(queryresult); lessthan // filters objects in which a specific key’s value is lesser than the provided value 1 let query = new parse query('profile'); 2 // lessthan can be used on numbers and dates 3 query lessthan('birthday', new date('08/19/1980')); 4 let queryresult = await query find(); 5 console log(queryresult); lessthanorequalto // filters objects in which a specific key’s value is lesser than or equal to the provided value 1 let query = new parse query('profile'); 2 // lessthanorequalto can be used on numbers and dates 3 query lessthanorequalto('friendcount', 49); 4 let queryresult = await query find(); 5 console log(queryresult); matches // filters objects in which a string type key value must match the provided regular expression and its modifiers 1 let query = new parse query('profile'); 2 // using the "i" modifier is a quick way to achieve 3 // case insensitive string querying 4 query matches('name', 'da', 'i'); 5 let queryresult = await query find(); 6 console log(queryresult); matcheskeyinquery // requires that a key’s value matches a value in an object returned by a different parse query useful for multi object querying 1 let query = new parse query('profile'); 2 // multiple queries can be combined using this, useful when there are more objects 3 // related, not our example case 4 query matcheskeyinquery('friendcount', 'friendcount', new parse query('profile') lessthan('friendcount', 50)); 5 query greaterthan('friendcount', 10); 6 let queryresult = await query find(); 7 console log(queryresult); matchesquery // requires that an object contained in the given key matches another query useful for multi object querying 1 let innerquery = new parse query('membership'); 2 innerquery greaterthan('expirationdate', new date()); 3 let query = new parse query('profile'); 4 query exists('premiummembership'); 5 query matchesquery('premiummembership', innerquery); 6 let queryresult = await query find(); 7 console log(queryresult); notequalto // filters objects in which a specific key’s value is not equal to the provided value 1 let query = new parse query('profile'); 2 // notequalto can be used in any data type 3 query notequalto("friendcount", 2); 4 let queryresult = await query find(); 5 console log(queryresult); startswith // filters objects in which a string key’s value starts with the provided text value 1 let query = new parse query('profile'); 2 // this is faster than other string searches by using backend index 3 query startswith('name', 'brit'); 4 let queryresult = await query find(); 5 console log(queryresult); query ordering essential in most queries, ordering can be easily achieved in parse and even chained between two or more ordering constraints addascending // sort the results in ascending order, overwrites previous orderings multiple keys can be used to solve ordering ties 1 let query = new parse query('profile'); 2 query addascending('friendcount'); 3 let queryresult = await query find(); 4 console log(queryresult); adddescending // sort the results in descending order, overwrites previous orderings multiple keys can be used to solve ordering ties 1 let query = new parse query('profile'); 2 query adddescending('friendcount'); 3 let queryresult = await query find(); 4 console log(queryresult); ascending // sort the results in ascending order, this can be chained without overwriting previous orderings multiple keys can be used to solve ordering ties 1 let query = new parse query('profile'); 2 query ascending('friendcount'); 3 let queryresult = await query find(); 4 console log(queryresult); descending // sort the results in descending order, this can be chained without overwriting previous orderings multiple keys can be used to solve ordering ties 1 let query = new parse query('profile'); 2 query descending('friendcount'); 3 let queryresult = await query find(); 4 console log(queryresult); sortbytextscore // sorts by text score when using parse query fulltext 1 let query = new parse query('profile'); 2 query fulltext('name', 'dan', { diacriticsensitive false, casesensitive false }); 3 query sortbytextscore(); 4 let queryresult = await query find(); 5 console log(queryresult); field selecting these methods affect which field values can be in your query results exclude // return all fields in the returned objects except the ones specified 1 let query = new parse query('profile'); 2 query exclude('name'); 3 let queryresult = await query find(); 4 console log(queryresult\[0] get('name') === undefined); 5 console log(queryresult\[0] get('birthday')); include // includes nested parse objects for the provided key 1 let query = new parse query('profile'); 2 query exists('premiummembership'); 3 query include('premiummembership'); 4 let queryresult = await query find(); 5 console log(queryresult\[0] get('premiummembership')); includeall // includes all nested parse objects 1 let query = new parse query('profile'); 2 query exists('premiummembership'); 3 query includeall(); 4 let queryresult = await query find(); 5 console log(queryresult\[0] get('premiummembership')); select // return only the specified fields in the returned objects 1 let query = new parse query('profile'); 2 query select('name'); 3 let queryresult = await query find(); 4 console log(queryresult\[0] get('birthday') === undefined); 5 console log(queryresult\[0] get('name')); geopoint querying these are methods specific to geopoint querying near // order objects by how near the key value is from the given geopoint 1 let query = new parse query('profile'); 2 query near('lastloginlocation', new parse geopoint(37 38412167489413, 122 01268034622319)); 3 let queryresult = await query find(); 4 console log(queryresult); polygoncontains // find objects whose key value contains the specified geopoint 1 let query = new parse query('profile'); 2 query polygoncontains('lastloginlocation', new parse geopoint(37 38412167489413, 122 01268034622319)); 3 let queryresult = await query find(); 4 console log(queryresult); withingeobox // find objects whose key value is contained within the specified bounding box, composed by two geopoint values that set the lower left and upper right corner values 1 let query = new parse query('profile'); 2 query withingeobox('lastloginlocation', new parse geopoint(37 48412167489413, 122 11268034622319), new parse geopoint(37 28412167489413, 121 91268034622319)); 3 let queryresult = await query find(); 4 console log(queryresult); withinkilometers // find objects whose key value is near the given geopoint and within the maxdistance value the sorted boolean value determines if the results should be sorted by distance ascending 1 let query = new parse query('profile'); 2 query withinkilometers('lastloginlocation', new parse geopoint(37 38412167489413, 122 01268034622319), 100, true); 3 let queryresult = await query find(); 4 console log(queryresult); withinmiles // find objects whose key value is near the given geopoint and within the maxdistance value the sorted boolean value determines if the results should be sorted by distance ascending 1 let query = new parse query('profile'); 2 query withinmiles('lastloginlocation', new parse geopoint(37 38412167489413, 122 01268034622319), 60, true); 3 let queryresult = await query find(); 4 console log(queryresult); withinpolygon // find objects whose key value is contained within the specified polygon, composed of an array of geopoints (at least three) if the polygon path is open, it will be closed automatically by parse connecting the last and first points 1 let query = new parse query('profile'); 2 query withinpolygon('lastloginlocation', \[new parse geopoint(37 48412167489413, 122 11268034622319), new parse geopoint(37 48412167489413, 121 91268034622319), new parse geopoint(37 28412167489413, 121 91268034622319), new parse geopoint(37 28412167489413, 122 01268034622319)]); 3 let queryresult = await query find(); 4 console log(queryresult); withinradians // find objects whose key value is near the given geopoint and within the maxdistance value the sorted boolean value determines if the results should be sorted by distance ascending 1 let query = new parse query('profile'); 2 query withinradians('lastloginlocation', new parse geopoint(37 38412167489413, 122 01268034622319), 1 5, true); 3 let queryresult = await query find(); 4 console log(queryresult); pagination these methods are related to pagination utilities, useful for queries that will retrieve a large number of results limit // sets the maximum value of returned results, the default value is 100 1 let query = new parse query('profile'); 2 query limit(2); 3 let queryresult = await query find(); 4 console log(queryresult); skip // skips the first n results in the query, essential for pagination 1 let query = new parse query('profile'); 2 query skip(2); 3 let queryresult = await query find(); 4 console log(queryresult); withcount // sets a flag that will wrap or not the query response in an object containing results, holding the array of parse object and count integer holding the total number of results 1 let query = new parse query('profile'); 2 query withcount(true); 3 let queryresult = await query find(); 4 console log(queryresult); response handling these methods are helpers for handling the query responses, making it possible to queue callbacks that will be called after your query is resolved they act as query resolvers as well, like find find and first first each // iterates over each result from the query and calls a callback for each one, in an unspecified order note that execution will halt on a rejected promise, so make sure to handle this case if using promises 1 let query = new parse query('profile'); 2 let queryresult = await query each((result) => console log(result)); 3 console log(queryresult); eachbatch // iterates over each result from the query and calls a callback for each batch of results, in an unspecified order the batchsize value needs to be passed inside the options object parameter, being the default 100 note that execution will halt on a rejected promise, so make sure to handle this case if using promises 1 let query = new parse query('profile'); 2 let queryresult = await query eachbatch((result) => console log(result), {batchsize 2}); 3 console log(queryresult); filter // iterates over each result from the query and calls a callback for each one, in an unspecified order note that execution will halt on a rejected promise, so make sure to handle this case if using promises differs from each for passing more parameters down on callback execution 1 let query = new parse query('profile'); 2 let queryresult = await query filter((currentobject, index, query) => console log(`${index} ${currentobject} ${query}`)); 3 console log(queryresult); map // iterates over each result from the query and calls a callback for each one, in an unspecified order note that execution will halt on a rejected promise, so make sure to handle this case if using promises differs from each for passing more parameters down on callback execution 1 let query = new parse query('profile'); 2 let queryresult = await query map((currentobject, index, query) => console log(`${index} ${currentobject} ${query}`)); 3 console log(queryresult); reduce // iterates over each result from the query and calls a callback for each one, in an unspecified order note that execution will halt on a rejected promise, so make sure to handle this case if using promises differs from each for passing more parameters down on callback execution and by allowing direct accumulator handling // the initialvalue is the value to use as the first argument to the first call of the callback if no initialvalue is supplied, the first object in the query will be used and skipped 1 let query = new parse query('profile'); 2 let queryresult = await query reduce((accumulator, currentobject, index) => console log(`${index} ${currentobject} ${accumulator}`)); 3 console log(queryresult); compound query these methods will create compound queries, which can combine more than one parse query parse query instance to achieve more complex results andquery // helper that is used by parse to add a constraint that all of passed in queries must match when using parse query and 1 let query1 = new parse query('profile'); 2 query1 greaterthan('friendcount', 10); 3 let query2 = new parse query('profile'); 4 query1 lessthan('friendcount', 50); 5 let query = new parse query('profile'); 6 query andquery(\[query1, query2]); 7 let queryresult = await query find(); 8 console log(queryresult); norquery // helper that is used by parse when using parse query nor 1 let query1 = new parse query('profile'); 2 query1 greaterthan('friendcount', 10); 3 let query2 = new parse query('profile'); 4 query1 lessthan('friendcount', 50); 5 let query = new parse query('profile'); 6 query norquery(\[query1, query2]); 7 let queryresult = await query find(); 8 console log(queryresult); orquery // helper that is used by parse to add a constraint that any of passed in queries must match when using parse query or 1 let query1 = new parse query('profile'); 2 query1 greaterthan('friendcount', 10); 3 let query2 = new parse query('profile'); 4 query1 lessthan('friendcount', 50); 5 let query = new parse query('profile'); 6 query orquery(\[query1, query2]); 7 let queryresult = await query find(); 8 console log(queryresult); and // compose a compound query that is the and of the passed queries 1 let query1 = new parse query('profile'); 2 query1 greaterthan('friendcount', 10); 3 let query2 = new parse query('profile'); 4 query1 lessthan('friendcount', 50); 5 let query = parse query and(query1, query2); 6 let queryresult = await query find(); 7 console log(queryresult); nor // compose a compound query that is the nor of the passed queries 1 let query1 = new parse query('profile'); 2 query1 greaterthan('friendcount', 10); 3 let query2 = new parse query('profile'); 4 query1 lessthan('friendcount', 50); 5 let query = parse query nor(query1, query2); 6 let queryresult = await query find(); 7 console log(queryresult); or // compose a compound query that is the or of the passed queries 1 let query1 = new parse query('profile'); 2 query1 greaterthan('friendcount', 10); 3 let query2 = new parse query('profile'); 4 query1 lessthan('friendcount', 50); 5 let query = parse query or(query1, query2); 6 let queryresult = await query find(); 7 console log(queryresult); database related these methods are related to the database preferences and operations aggregate // executes an aggregate query, retrieving objects over a set of input values please refer to mongodb documentation on aggregate(https //docs mongodb com/v3 2/reference/operator/aggregation/)for better understanding 1 let query = new parse query('profile'); 2 let queryresult = await query aggregate({ limit 5 }); 3 console log(queryresult); explain // investigates the query execution plan, related to mongodb explain operation 1 let query = new parse query('profile'); 2 query explain(true); 3 let queryresult = await query find(); 4 console log(queryresult); readpreference // when using a mongodb replica set, use this method to choose from which replica the objects will be retrieved the possible values are primary (default), primary preferred, secondary, secondary preferred, or nearest 1 let query = new parse query('profile'); 2 query readpreference("primary"); 3 let queryresult = await query find(); 4 console log(queryresult); local datastore these methods enable selecting the source of the queries and using a local datastore fromlocaldatastore // changes the source of this query to all pinned objects 1 // this should be set before using fromlocaldatastore 2 parse enablelocaldatastore(); 3 let query = new parse query('profile'); 4 query fromlocaldatastore(); 5 let queryresult = await query find(); 6 console log(queryresult); fromnetwork // changes the source of this query to your online server 1 let query = new parse query('profile'); 2 query fromnetwork(); 3 let queryresult = await query find(); 4 console log(queryresult); frompin // changes the source of this query to the default group of pinned objects 1 let query = new parse query('profile'); 2 query frompin(); 3 let queryresult = await query find(); 4 console log(queryresult); frompinwithname // changes the source of this query to a specific group of pinned objects 1 let query = new parse query('profile'); 2 query frompinwithname('pinnedobjects'); 3 let queryresult = await query find(); 4 console log(queryresult); json specifics methods that allow queries to be represented as json and retrieved tojson // returns a json representation of this query operations 1 let query = new parse query('profile'); 2 query greaterthan('friendcount', 10); 3 let queryjson = await query tojson(); 4 console log(queryjson); withjson // add a previously generated json representation of query operations to this query 1 let query = new parse query('profile'); 2 query greaterthan('friendcount', 10); 3 let queryjson = await query tojson(); 4 let query2 = new parse query('profile'); 5 query2 withjson(queryjson); 6 let queryresult = await query2 find(); 7 console log(queryresult); // static method to restore parse query by json representation, internally calling parse query withjson 1 let query = new parse query('profile'); 2 query greaterthan('friendcount', 10); 3 let queryjson = await query tojson(); 4 let query2 = parse query withjson('profile', queryjson); 5 let queryresult = await query2 find(); 6 console log(queryresult); conclusion at the end of this guide, you learned how to perform every data query method in parse in the next guide, you will learn about relational parse querying in react