ReactJS
Data objects
Mengoptimalkan Kueri dengan Parse di Aplikasi React
22 mnt
buku resep react query untuk parse pendahuluan kami sudah melihat bagaimana parse query parse query dengan get get dapat mengambil satu parse object parse object dari back4app ada banyak cara lain untuk mengambil data dengan parse query parse query anda dapat mengambil banyak objek sekaligus, menggunakan kondisi pada objek yang ingin anda ambil, dan banyak lagi dalam panduan ini, anda akan mendalami parse query parse query kelas dan melihat semua metode yang dapat anda gunakan untuk membangun query anda anda akan menggunakan kelas database sederhana dengan beberapa data yang dipalsukan untuk melakukan query menggunakan konsol javascript di back4app prasyarat untuk menyelesaikan tutorial ini, anda akan membutuhkan sebuah aplikasi dibuat di back4app tujuan jelajahi parse query parse query kelas metode yang berbeda kelas parse query setiap operasi kueri di parse menggunakan tipe objek parse query parse query , yang akan membantu anda mengambil data spesifik dari back4app di seluruh aplikasi anda untuk membuat parse query parse query , anda perlu melewatkan sebagai parameter parse object parse object subclass yang diinginkan, yang akan berisi hasil kueri anda sangat penting untuk mengetahui bahwa parse query parse query hanya akan terpecahkan setelah memanggil metode retrieve (seperti parse query find parse query find atau parse query get parse query get ), jadi kueri dapat disiapkan dan beberapa modifikasi dapat dirangkai sebelum benar benar dipanggil anda dapat membaca lebih lanjut tentang parse query parse query kelas di sini pada dokumentasi resmi https //parseplatform org/parse sdk js/api/master/parse query html menggunakan konsol js di back4app di dalam dasbor aplikasi back4app anda, anda akan menemukan konsol api yang sangat berguna di mana anda dapat menjalankan kode javascript secara langsung dalam panduan ini, anda akan menggunakan untuk menyimpan dan mengkueri objek data dari back4app di dasbor utama aplikasi anda, pergi ke core >api console >js console core >api console >js console simpan objek data anda untuk menjalankan kueri pada panduan ini, anda perlu terlebih dahulu mengisi aplikasi anda dengan beberapa data mari kita buat kelas contoh yang disebut profil profil , yang meniru kelas profil media sosial menggunakan nama nama orang terkenal dan bidang bidang berikut tipe string nama nama ; tipe tanggal harilahir harilahir ; tipe angka (integer) jumlahteman jumlahteman ; tipe array (array string) makananfavorit makananfavorit ; tipe array (array angka) nomorkeberuntungan nomorkeberuntungan ; tipe geopoint lokasiloginterakhir lokasiloginterakhir ; tipe pointer nullable keanggotaanpremium keanggotaanpremium , terkait dengan sebuah keanggotaan keanggotaan kelas yang berisi string nama nama dan tanggal tanggalkedaluwarsa tanggalkedaluwarsa bidang berikut adalah parse object parse object kode pembuatan kelas, jadi silakan jalankan di konsol api anda 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!'); setelah menjalankan kode ini, anda sekarang harus memiliki sebuah profil profil kelas di database anda dengan enam objek yang dibuat kelas baru anda harus terlihat seperti ini mari kita sekarang melihat contoh dari setiap parse query parse query metode, bersama dengan penjelasan singkat tentang apa yang mereka lakukan harap dicatat bahwa beberapa metode dalam daftar ini dapat mengambil opsi opsi sebagai argumen tambahan, tetapi dalam banyak kasus, itu hanya terkait dengan masterkey masterkey penggunaan dan tidak relevan dengan konten panduan ini, jadi kemungkinan ini akan diabaikan kapan pun tidak relevan pengambil kueri metode ini bertanggung jawab untuk menjalankan kueri dan mengambil hasilnya, selalu ada dalam implementasi kueri anda 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); 	 kondisi kueri metode ini memberi anda kemungkinan untuk menerapkan batasan kondisional pada kueri anda, yang bisa dibilang adalah operasi yang paling penting dalam pengkuerian ingatlah bahwa semua operasi ini dapat dirangkai sebelum hasil diambil, sehingga banyak kombinasi dapat dicapai untuk memenuhi kebutuhan pengkuerian anda 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); pengurutan kueri esensial dalam sebagian besar kueri, pengurutan dapat dengan mudah dicapai di parse dan bahkan dirantai antara dua atau lebih batasan pengurutan 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); pemilihan field metode ini mempengaruhi nilai field mana yang dapat ada dalam hasil kueri anda 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')); pencarian geopoint ini adalah metode yang spesifik untuk pencarian geopoint 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); paginasi metode ini terkait dengan utilitas paginasi, berguna untuk kueri yang akan mengambil sejumlah besar hasil 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); penanganan respons metode ini adalah pembantu untuk menangani respons kueri, membuatnya mungkin untuk mengantri callback yang akan dipanggil setelah kueri anda diselesaikan mereka juga bertindak sebagai resolver kueri, seperti find find dan 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); kueri gabungan metode ini akan membuat kueri gabungan, yang dapat menggabungkan lebih dari satu parse query parse query instansi untuk mencapai hasil yang lebih kompleks 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); terkait database metode ini terkait dengan preferensi dan operasi basis data 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); penyimpanan lokal metode ini memungkinkan pemilihan sumber kueri dan menggunakan penyimpanan lokal 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); spesifikasi json metode yang memungkinkan kueri direpresentasikan sebagai json dan diambil 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); kesimpulan di akhir panduan ini, anda telah belajar bagaimana melakukan setiap metode kueri data di parse di panduan berikutnya, anda akan belajar tentang kueri relasional parse di react