Pleex
Search…
insertMultiple
Insert multiple items with a single schema to collection

insertMultipe({data}, schema, (success)=> {}, (error)=> {})

How to use:

1
my_collection.insertMultiple(
2
[
3
{key: value},
4
{key: value}
5
],
6
schema,
7
() => // removed successfully,
8
(error) => alert(error)
9
);
Copied!

Arguments:

parameter
required
types
data (input)
yes
array of objects
schema
yes
schema variable
success callback
yes
function
failure callback
yes
function

Example:

1
import React,{useEffect} from 'react';
2
import {Text} from 'react-native';
3
import {Pleex} from 'pleex';
4
5
const App = () => {
6
7
// Create collection
8
const my_collection = Pleex.collection('myCollection');
9
10
// Create schema
11
const my_schema = Pleex.schema({
12
name: String,
13
});
14
15
// Insert to my collection
16
my_collection.insertMultiple(
17
[
18
{name: 'John'},
19
{name: 'Smith'},
20
{name: 'Sara'}
21
],
22
mySchema,
23
(success) => alert('success'),
24
(error) => alert(error)
25
);
26
27
return (
28
<>
29
<Text>Try Multiple insert</Text>
30
</>
31
);
32
33
};
34
35
export default App;
Copied!