CRUD PUT

Update data in your database

Using node/bun:

import datasquirel from "@moduletrace/datasquirel";

datasquirel.api
    .crud({
        database: "social_network",
        table: "users",
        key: process.env.FULL_ACCESS_API_KEY,
        params: {
            action: "update",
            targetId: 1,
            data: {
                name: "John",
                email: "[email protected]",
            },
        },
    })
    .then((response) => {
        console.log(response);
    });

Using curl:

CURL -X PUT https://datasquirel.com/api/v1/social_network/users/1 \
-H "Authorization:FULL_ACCESS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "John", "email": "[email protected]"}'


Resulting SQL:

UPDATE users SET name = 'John', email = '[email protected]' WHERE id = 1;

Return Response:

{
    success: true,
    payload: {
        affectedRows: 1,
        insertId: 0,
        info: "",
        serverStatus: 2,
        warningStatus: 0,
    },
    "queryRes": {
        "string": "UPDATE users SET name = ?, email = ? WHERE id = ?",
        "values": ["John", "[email protected]", 1]
    }
}