CRUD PUT
Update data in your database
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);
});
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]"}'
{
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]
}
}