CRUD OPTIONS
Run any crud actionThe OPTIONS
action is used to handle every crud action. insert
, get
, update
, and delete
.
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: "get", query: { limit: 10, }, }, }) .then((response) => { console.log(response); });
Using curl:
CURL -X OPTIONS https://datasquirel.com/api/v1/social_network/users \ -H "Authorization:FULL_ACCESS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "action": "get", "query": { "limit": 10 } }'
Resulting SQL:
SELECT * FROM users LIMIT 10;
Return Response:
{ success: true, payload: [ { id: 1, name: "John", email: "[email protected]", }, { id: 2, name: "Jane", email: "[email protected]", }, ], "queryRes": { "string": "SELECT * FROM users LIMIT 10", "values": [] } }