@picobase_app/client 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -198,6 +198,39 @@ const token = await pb.storage.getFileToken()
|
|
|
198
198
|
const protectedUrl = pb.storage.getFileUrl(user, 'document.pdf', { token })
|
|
199
199
|
```
|
|
200
200
|
|
|
201
|
+
## Admin API (Collection Management)
|
|
202
|
+
|
|
203
|
+
The SDK provides an admin module that allows you to programmatically manage your PicoBase collections. **This requires an admin API key** to be used during client initialization.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// Initializing with an admin API key
|
|
207
|
+
const adminPb = createClient('https://myapp.picobase.com', 'pbk_admin_xxxxxxxx')
|
|
208
|
+
|
|
209
|
+
// Create a new collection
|
|
210
|
+
const usersCollection = await adminPb.admin.createCollection({
|
|
211
|
+
name: "custom_users",
|
|
212
|
+
type: "base",
|
|
213
|
+
schema: [
|
|
214
|
+
{ name: "full_name", type: "text", required: true },
|
|
215
|
+
{ name: "age", type: "number" }
|
|
216
|
+
]
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
// List all collections
|
|
220
|
+
const collections = await adminPb.admin.listCollections()
|
|
221
|
+
|
|
222
|
+
// Get a single collection
|
|
223
|
+
const collection = await adminPb.admin.getCollection('custom_users')
|
|
224
|
+
|
|
225
|
+
// Update an existing collection
|
|
226
|
+
const updated = await adminPb.admin.updateCollection('custom_users', {
|
|
227
|
+
name: "users_updated"
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
// Delete a collection
|
|
231
|
+
const success = await adminPb.admin.deleteCollection('users_updated')
|
|
232
|
+
```
|
|
233
|
+
|
|
201
234
|
## Advanced
|
|
202
235
|
|
|
203
236
|
### Custom auth collection
|