🚀 API Maker - Save Single or Multiple API Records [Bulk Insert] [Post operation]
Tags: javascript, mongodb, node, developers
Published: 2023-08-21 03:38:27


✅ This API is available in all major 8 database types in **[API Maker](https://apimaker.dev)**
- **MongoDB**
- **MySQL**
- **SQL Server**
- **MariaDB**
- **Oracle DB**
- **PostgreSQL DB**
- **TiDB**
- **Percona XtraDB**


✅ User can save single or multiple records 
   ▸ having some inbuilt validation and conversion functionality.

✅ Generate Dummy Payload [Single | Multiple]
   ▸ Based on schema, user can generate dummy data with a single click by using Generated Data option in body section.
   ▸ To generate your data it will not perform any kind of operation on database.it will guess the data based on field name and types.

✅ Modify response using Query Params [select | deep]
   ▸ select - Retrieve the fields based on the user's needs.
   ▸ deep - Obtain more precise / details data in a certain field.

✅ This API work like Atomic operation [either save all or none] 
   ▸ for single object inside the array, entire array input will not be considered as atomic operation.


-----------------
⭐ Validation ⭐
-----------------
👉 API Maker validate the payload using below validator.
   ▸ required
   ▸ email
   ▸ max
   ▸ maxLength
   ▸ min
   ▸ minLength
   ▸ unique
   ▸ validatorFun [Custom validator function]

-----------------
⭐ Conversion ⭐
-----------------
👉 API Maker can convert the payload using below conversion.
   ▸ encryption
   ▸ hashing
   ▸ toLowerCase
   ▸ toUpperCase
   ▸ trim
   ▸ trimStart
   ▸ trimEnd
   ▸ conversionFun [Custom conversion function]


-----------------
⭐ API Example ⭐
-----------------

```json
[
    {
        "first_name": "Bob",
        "last_name": "Lin"
    },
    {
        "first_name": "Alice",
        "last_name": "Page"
    }
]
```


---------------------
⭐ Example in code ⭐
---------------------

```javascript
// Perform bulk insert operation in schema based API
let saveSingleOrMultiple = await g.sys.db.saveSingleOrMultiple({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    saveData: [{
        "first_name": "Bob",
        "last_name": "Lin"
    },
    {
        "first_name": "Alice",
        "last_name": "Page"
    }]
});
```

```javascript
// Perform bulk insert operation in generated API, only for mongoDB
let saveSingleOrMultiple = await g.sys.db.gen.saveSingleOrMultipleGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    saveData: [{
        "first_name": "Bob",
        "last_name": "Lin"
    },
    {
        "first_name": "Alice",
        "last_name": "Page"
    }]
});
```



-----------------

## Youtube video link
https://youtu.be/UmEVfKf2O6M


## Websites
https://apimaker.dev


## API Docs links
https://docs.apimaker.dev/v1/docs/apis-all/generated-apis/auto-generated-save-single-or-multiple-api.html

https://docs.apimaker.dev/v1/docs/apis-all/schema-apis/auto-generated-schema-based-save-single-or-multiple-api.html


## More Examples
https://docs.apimaker.dev/v1/examples/sys/db/saveSingleOrMultiple.html

https://docs.apimaker.dev/v1/examples/sys/db/gen/saveSingleOrMultipleGen.html


## Follow on twitter
https://twitter.com/api_maker


## Linked In
https://www.linkedin.com/company/api-maker

## More YouTube Videos
https://www.youtube.com/@api_maker/playlists