getItem

Find and get objects, this is for single results

getItem({key: value, ...} , (data)=> {}, (error)=> {})

How to use:

my_collection.getItem(
    {key: value},
    (data) =>  // data can access here,
    (error) => alert(error) 
);

Arguments:

parameter

required

types

search object

yes

object

success callback

yes

function

failure callback

yes

function

Example:

import React,{useEffect} from 'react';
import {Text} from 'react-native';
import {Pleex} from 'pleex';

const App = () => {
  
  // Create collection
  const my_collection = Pleex.collection('myCollection');
  
  // Get all data saved
  my_collection.getItem(
    { age: 12 },
    (data) =>  // data can access here,
    (error) => alert(error) 
  );
  
  return (
    <>
      <Text>Try getItem api</Text>
    </>
  );

};

export default App;

Tips:

  1. if many items exists and matches with object you provide, getItem only return the last matched one.

  2. to get list of matched items use getItems.

  3. if pleex don't find anything its return undefined

Last updated

Was this helpful?