ReactJS
Data objects
Parse.Query für React: Methoden und Nutzung
22 min
react query kochbuch für parse einführung wir haben bereits gesehen, wie eine parse query parse query mit get get ein einzelnes parse object parse object von back4app abrufen kann es gibt viele andere möglichkeiten, daten mit parse query parse query abzurufen sie können viele objekte auf einmal abrufen, bedingungen für die objekte verwenden, die sie abrufen möchten, und mehr in diesem leitfaden werden sie tief in die parse query parse query klasse eintauchen und alle methoden sehen, die sie verwenden können, um ihre abfragen zu erstellen sie werden eine einfache datenbankklasse mit einigen gemockten daten verwenden, um die abfragen über die javascript konsole auf back4app durchzuführen voraussetzungen um dieses tutorial abzuschließen, benötigen sie eine app die auf back4app erstellt wurde ziel erforschen sie die parse query parse query klasse und deren verschiedene methoden die parse query klasse jede abfrageoperation auf parse verwendet den parse query parse query objekttyp, der ihnen hilft, spezifische daten von ihrem back4app in ihrer app abzurufen um eine neue parse query parse query , müssen sie als parameter die gewünschte parse object parse object unterklasse übergeben, die die abfrageergebnisse enthalten wird es ist entscheidend zu wissen, dass ein parse query parse query nur nach dem aufruf einer abrufmethode (wie parse query find parse query find oder parse query get parse query get ) aufgelöst wird, sodass eine abfrage eingerichtet und mehrere modifikatoren verkettet werden können, bevor sie tatsächlich aufgerufen wird sie können mehr über die parse query parse query klasse hier in der offiziellen dokumentation https //parseplatform org/parse sdk js/api/master/parse query html lesen verwendung der js konsole auf back4app in ihrem back4app anwendungs dashboard finden sie eine sehr nützliche api konsole, in der sie javascript code direkt ausführen können in diesem leitfaden werden sie sie verwenden, um datenobjekte von back4app zu speichern und abzufragen gehen sie auf ihrem haupt dashboard der app zu core >api console >js console core >api console >js console speichern sie ihre datenobjekte um die abfragen in diesem leitfaden auszuführen, müssen sie zunächst ihre app mit einigen daten füllen lassen sie uns eine beispielklasse namens profil profil , die eine soziale medienprofilklasse mit namen berühmter personen und den folgenden feldern nachahmt string typ name name ; datumstyp geburtstag geburtstag ; zahl (ganzzahlig) typ freundzahl freundzahl ; array (string array) typ lieblingsnahrungsmittel lieblingsnahrungsmittel ; array (zahlen array) typ glückszahlen glückszahlen ; geopoint typ letzteanmeldestandort letzteanmeldestandort ; nullable pointer typ premiummitgliedschaft premiummitgliedschaft , die sich auf eine mitgliedschaft mitgliedschaft klasse bezieht, die einen string enthält name name und datum ablaufdatum ablaufdatum felder hier ist der parse object parse object klassen erstellungscode, also mach weiter und führe ihn in deiner api konsole aus 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!'); nachdem sie diesen code ausgeführt haben, sollten sie jetzt eine profil profil klasse in ihrer datenbank mit sechs erstellten objekten haben ihre neue klasse sollte folgendermaßen aussehen lassen sie uns nun beispiele von jeder parse query parse query methode ansehen, zusammen mit kurzen erklärungen, was sie tun bitte beachten sie, dass einige methoden in dieser liste optionen optionen als zusätzliches argument annehmen können, aber in den meisten fällen bezieht es sich nur auf masterkey masterkey verwendung und ist für den inhalt dieses leitfadens nicht relevant, daher wird diese möglichkeit weggelassen, wann immer sie nicht relevant ist abfrage retriever diese methoden sind dafür verantwortlich, die abfrage auszuführen und ihre ergebnisse abzurufen, und sind immer in ihrer abfrageimplementierung vorhanden 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); 	 abfragebedingungen diese methoden geben ihnen die möglichkeit, bedingte einschränkungen auf ihre abfrage anzuwenden, die arguably die wichtigsten operationen beim abfragen sind denken sie daran, dass diese operationen alle verkettet werden können, bevor die ergebnisse abgerufen werden, sodass viele kombinationen erreicht werden können, um ihre abfragebedürfnisse zu erfüllen 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); abfrageordnung wesentlich in den meisten abfragen, kann die ordnung in parse leicht erreicht und sogar zwischen zwei oder mehr ordnungsbedingungen verkettet werden 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); feldauswahl diese methoden beeinflussen, welche feldwerte in ihren abfrageergebnissen enthalten sein können 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 abfrage dies sind methoden, die spezifisch für die geopoint abfrage sind 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); seitenpagination diese methoden beziehen sich auf pagination utilities, die nützlich sind für abfragen, die eine große anzahl von ergebnissen abrufen 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); antwortverarbeitung diese methoden sind helfer für die verarbeitung der abfrageantworten, die es ermöglichen, rückrufe in eine warteschlange zu stellen, die nach der auflösung ihrer abfrage aufgerufen werden sie fungieren auch als abfrage resolver, wie finden finden und erste erste 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); kombinierte abfrage diese methoden erstellen kombinierte abfragen, die mehr als eine parse query parse query instanz kombinieren, um komplexere ergebnisse zu erzielen 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); datenbankbezogen diese methoden beziehen sich auf die datenbankpräferenzen und operationen 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); lokaler datenspeicher diese methoden ermöglichen die auswahl der quelle der abfragen und die verwendung eines lokalen datenspeichers 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 spezifika methoden, die es ermöglichen, abfragen als json darzustellen und abzurufen 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); fazit am ende dieses leitfadens haben sie gelernt, wie sie jede datenabfragemethode in parse durchführen im nächsten leitfaden werden sie etwas über relationale parse abfragen in react lernen