DEV Community

Cover image for 🚀 API Maker - Save Single or Multiple API Records [Bulk Insert] [Post operation]
API Maker®
API Maker®

Posted on

4 3 1 2

🚀 API Maker - Save Single or Multiple API Records [Bulk Insert] [Post operation]

✅ This API is available in all major 8 database types in API Maker

  • 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 ⭐

[
    {
        "first_name": "Bob",
        "last_name": "Lin"
    },
    {
        "first_name": "Alice",
        "last_name": "Page"
    }
]
Enter fullscreen mode Exit fullscreen mode

⭐ Example in code ⭐

// 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"
    }]
});
Enter fullscreen mode Exit fullscreen mode
// 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"
    }]
});
Enter fullscreen mode Exit fullscreen mode

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

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up