Repository navigation
fix: harden populate robustness, clamp paginate limit, fix docs and test coverage #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,33 @@ curl "https://api.ub.bitbros.in/api/data/posts/64fd1234abcd5678ef901234" ^ | |
| -H "x-api-key: pk_live_xxx" | ||
| ``` | ||
|
|
||
| ## 2.1 Query Parameters | ||
|
|
||
| You can refine your `GET` requests using the following query parameters: | ||
|
|
||
|
Comment on lines
+64
to
+67
|
||
| | Parameter | Type | Example | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | `populate` | `String` | `?populate=author,category` | Expand `Ref` fields into full objects. | | ||
| | `expand` | `String` | `?expand=author` | Alias for `populate`. | | ||
| | `sort` | `String` | `?sort=createdAt:desc` | Sort results by field and order. | | ||
| | `limit` | `Number` | `?limit=25` | Number of documents to return (default: 100, max: 100). | | ||
| | `page` | `Number` | `?page=2` | 1-indexed page number for pagination. | | ||
|
|
||
| ### Relational Data (Population) 🔗 | ||
|
|
||
| If you have fields defined as `Ref` (singular) or `Array of Ref` in your schema, urBackend can automatically join those documents for you. | ||
|
|
||
| By default, urBackend returns raw IDs for references. Use `?populate=` to get the full nested object. | ||
|
|
||
| ```bash | ||
| # Get posts with full author and category objects | ||
| curl "https://api.ub.bitbros.in/api/data/posts?populate=author,category" ^ | ||
| -H "x-api-key: pk_live_xxx" | ||
| ``` | ||
|
|
||
| > [!TIP] | ||
| > This solves the N+1 query problem, allowing you to fetch complex relational data in a single request. | ||
|
|
||
| ## 3. Update a Document | ||
|
|
||
| **Endpoint**: `PUT /api/data/:collectionName/:id` | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.