@@ -10,6 +10,7 @@ OpenAPI (Swagger) docs, and zero code generation.
1010
1111- Auto-discovers tables and columns
1212- Full CRUD endpoints for any table
13+ - ** Bulk operations** - Create or delete multiple records efficiently
1314- Configurable authentication (API Key, Basic Auth, JWT, or none)
1415- ** Advanced query features:**
1516 - ** Field selection** - Choose specific columns to return
@@ -92,28 +93,104 @@ return [
9293
9394All requests go through ` public/index.php ` with ` action ` parameter.
9495
95- | Action | Method | Usage Example |
96- | -----------| --------| ------------------------------------------------------------|
97- | tables | GET | ` /index.php?action=tables ` |
98- | columns | GET | ` /index.php?action=columns&table=users ` |
99- | list | GET | ` /index.php?action=list&table=users ` |
100- | read | GET | ` /index.php?action=read&table=users&id=1 ` |
101- | create | POST | ` /index.php?action=create&table=users ` (form POST) |
102- | update | POST | ` /index.php?action=update&table=users&id=1 ` (form POST) |
103- | delete | POST | ` /index.php?action=delete&table=users&id=1 ` |
104- | openapi | GET | ` /index.php?action=openapi ` |
105- | login | POST | ` /index.php?action=login ` (JWT only) |
96+ | Action | Method | Usage Example |
97+ | --------------| --------| -------------------------------------------------------------|
98+ | tables | GET | ` /index.php?action=tables ` |
99+ | columns | GET | ` /index.php?action=columns&table=users ` |
100+ | list | GET | ` /index.php?action=list&table=users ` |
101+ | read | GET | ` /index.php?action=read&table=users&id=1 ` |
102+ | create | POST | ` /index.php?action=create&table=users ` (form POST or JSON) |
103+ | update | POST | ` /index.php?action=update&table=users&id=1 ` (form POST or JSON) |
104+ | delete | POST | ` /index.php?action=delete&table=users&id=1 ` |
105+ | bulk_create | POST | ` /index.php?action=bulk_create&table=users ` (JSON array) |
106+ | bulk_delete | POST | ` /index.php?action=bulk_delete&table=users ` (JSON with ids) |
107+ | openapi | GET | ` /index.php?action=openapi ` |
108+ | login | POST | ` /index.php?action=login ` (JWT only) |
106109
107110---
108111
109112## 🤖 Example ` curl ` Commands
110113
111114``` sh
115+ # List tables
112116curl http://localhost/index.php? action=tables
117+
118+ # List users with API key
113119curl -H " X-API-Key: changeme123" " http://localhost/index.php?action=list&table=users"
120+
121+ # JWT login
114122curl -X POST -d " username=admin&password=secret" http://localhost/index.php? action=login
123+
124+ # List with JWT token
115125curl -H " Authorization: Bearer <token>" " http://localhost/index.php?action=list&table=users"
126+
127+ # Basic auth
116128curl -u admin:secret " http://localhost/index.php?action=list&table=users"
129+
130+ # Bulk create
131+ curl -X POST -H " Content-Type: application/json" \
132+ -d ' [{"name":"Alice","email":"alice@example.com"},{"name":"Bob","email":"bob@example.com"}]' \
133+ " http://localhost/index.php?action=bulk_create&table=users"
134+
135+ # Bulk delete
136+ curl -X POST -H " Content-Type: application/json" \
137+ -d ' {"ids":[1,2,3]}' \
138+ " http://localhost/index.php?action=bulk_delete&table=users"
139+ ```
140+
141+ ---
142+
143+ ### 💪 Bulk Operations
144+
145+ The API supports bulk operations for efficient handling of multiple records:
146+
147+ #### Bulk Create
148+
149+ Create multiple records in a single transaction. If any record fails, the entire operation is rolled back.
150+
151+ ** Endpoint:** ` POST /index.php?action=bulk_create&table=users `
152+
153+ ** Request Body (JSON array):**
154+ ``` json
155+ [
156+ {"name" : " Alice" , "email" : " alice@example.com" , "age" : 25 },
157+ {"name" : " Bob" , "email" : " bob@example.com" , "age" : 30 },
158+ {"name" : " Charlie" , "email" : " charlie@example.com" , "age" : 35 }
159+ ]
160+ ```
161+
162+ ** Response:**
163+ ``` json
164+ {
165+ "success" : true ,
166+ "created" : 3 ,
167+ "data" : [
168+ {"id" : 1 , "name" : " Alice" , "email" : " alice@example.com" , "age" : 25 },
169+ {"id" : 2 , "name" : " Bob" , "email" : " bob@example.com" , "age" : 30 },
170+ {"id" : 3 , "name" : " Charlie" , "email" : " charlie@example.com" , "age" : 35 }
171+ ]
172+ }
173+ ```
174+
175+ #### Bulk Delete
176+
177+ Delete multiple records by their IDs in a single query.
178+
179+ ** Endpoint:** ` POST /index.php?action=bulk_delete&table=users `
180+
181+ ** Request Body (JSON):**
182+ ``` json
183+ {
184+ "ids" : [1 , 2 , 3 , 4 , 5 ]
185+ }
186+ ```
187+
188+ ** Response:**
189+ ``` json
190+ {
191+ "success" : true ,
192+ "deleted" : 5
193+ }
117194```
118195
119196---
0 commit comments