Insert
Insert to collections, by this method you can insert data with your schema's into your collection
insert({data}, schema, (success)=> {}, (error)=> {})
insert({data}, schema, (success)=> {}, (error)=> {})
How to use:
my_collection.insert(
{key: value},
mySchema,
(success) => alert('Hoorai'),
(error) => alert(error)
);
Arguments:
parameter
required
types
data
yes
object
schema
yes
schema variable
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');
// Create schema
const my_schema = Pleex.schema({
name: String,
age: Number,
logged: Boolean,
});
// Insert to my collection
my_collection.insert(
{
name: 'John',
age: 12,
logged: false
},
mySchema,
(success) => alert('success'),
(error) => alert(error)
);
return (
<>
<Text>Try Schemas</Text>
</>
);
};
export default App;
Last updated
Was this helpful?