Skip to content

Commit 0d03737

Browse files
Copilothotlong
andcommitted
Update remaining documentation files with new query syntax
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent b4acbd7 commit 0d03737

File tree

8 files changed

+34
-38
lines changed

8 files changed

+34
-38
lines changed

content/docs/ai/coding-assistant.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Without this prompt, Copilot assumes you are using a generic ORM (like TypeORM)
2121
With the System Prompt, it understands the **Context + Repository** pattern:
2222

2323
> **Good AI Output:**
24-
> `await ctx.object('todo').find({ filters: [['priority', '=', 'high']] })`
24+
> `await ctx.object('todo').find({ filters: { priority: 'high' } })`
2525
2626
### 2. Prompting Strategy
2727

@@ -103,10 +103,10 @@ Use the standard generic CRUD API via a context.
103103
const ctx = app.createContext({});
104104
105105
const todos = await ctx.object('todo').find({
106-
filters: [
107-
['completed', '=', false],
108-
['priority', '=', 'high']
109-
],
106+
filters: {
107+
completed: false,
108+
priority: 'high'
109+
},
110110
fields: ['title', 'owner.name'], // Select specific fields & relations
111111
sort: [['created_at', 'desc']],
112112
skip: 0,

content/docs/data-access/index.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ const ctx = app.createContext({ isSystem: true });
6161
// Query data with filters
6262
const products = await ctx.object('product').find({
6363
fields: ['name', 'price', 'category'],
64-
filters: [
65-
['category', '=', 'electronics'],
66-
'and',
67-
['price', '<', 1000]
68-
],
64+
filters: {
65+
category: 'electronics',
66+
price: { $lt: 1000 }
67+
},
6968
sort: [['price', 'asc']],
7069
top: 10
7170
});

content/docs/modeling/migrations.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ The MongoDB driver now automatically maps between `id` (API) and `_id` (database
2828
```typescript
2929
// MongoDB-specific code
3030
const query = {
31-
filters: [['_id', '=', 'user-123']]
31+
filters: { _id: 'user-123' }
3232
};
3333
```
3434

3535
**After:**
3636
```typescript
3737
// Works with both MongoDB and SQL
3838
const query = {
39-
filters: [['id', '=', 'user-123']]
39+
filters: { id: 'user-123' }
4040
};
4141
```
4242

@@ -147,7 +147,7 @@ The MongoDB driver maintains **full backward compatibility** for `_id` usage:
147147
```typescript
148148
// Legacy code - fully supported for backward compatibility
149149
const query = {
150-
filters: [['_id', '=', 'user-123']],
150+
filters: { _id: 'user-123' },
151151
sort: [['_id', 'desc']],
152152
fields: ['_id', 'name', 'email']
153153
};
@@ -196,7 +196,7 @@ assert(user._id === undefined); // Should not have _id
196196
### 2. Find Operations
197197
```typescript
198198
const users = await app.find('users', {
199-
filters: [['id', '=', 'test-123']]
199+
filters: { id: 'test-123' }
200200
});
201201
assert(users[0].id === 'test-123');
202202
```

content/docs/reference/api/client-sdk.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ console.log(updated.updated_at); // New timestamp
127127

128128
```typescript
129129
const result = await dataClient.updateMany('users', {
130-
filters: [['status', '=', 'pending']],
130+
filters: { status: 'pending' },
131131
data: { status: 'active' }
132132
});
133133
```
@@ -143,7 +143,7 @@ console.log(result.success);
143143

144144
```typescript
145145
const result = await dataClient.deleteMany('users', {
146-
filters: [['created_at', '<', '2023-01-01']]
146+
filters: { created_at: { $lt: '2023-01-01' } }
147147
});
148148

149149
console.log(result.deleted_count);
@@ -152,9 +152,9 @@ console.log(result.deleted_count);
152152
### Count Records
153153

154154
```typescript
155-
const countResult = await dataClient.count('users', [
156-
['status', '=', 'active']
157-
]);
155+
const countResult = await dataClient.count('users', {
156+
status: 'active'
157+
});
158158

159159
console.log(countResult.count);
160160
```

content/docs/reference/api/examples.mdx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ const response = await fetch('/api/objectql', {
6666
{ func: 'count', field: 'id', alias: 'order_count' },
6767
{ func: 'avg', field: 'amount', alias: 'avg_order_value' }
6868
],
69-
filters: [
70-
['status', '=', 'paid'],
71-
'and',
72-
['created_at', '>=', '2024-01-01']
73-
],
69+
filters: {
70+
status: 'paid',
71+
created_at: { $gte: '2024-01-01' }
72+
},
7473
sort: [['month', 'asc'], ['revenue', 'desc']]
7574
}
7675
})
@@ -99,19 +98,17 @@ const response = await fetch('/api/objectql', {
9998
object: 'customers',
10099
args: {
101100
fields: ['name', 'email', 'vip_level', 'total_spent'],
102-
filters: [
103-
['vip_level', '>=', 'gold'],
104-
'and',
105-
['is_active', '=', true]
106-
],
101+
filters: {
102+
vip_level: { $gte: 'gold' },
103+
is_active: true
104+
},
107105
expand: {
108106
orders: {
109107
fields: ['order_no', 'amount', 'status'],
110-
filters: [
111-
['created_at', '>', '2024-01-01'],
112-
'and',
113-
['amount', '>', 1000]
114-
],
108+
filters: {
109+
created_at: { $gt: '2024-01-01' },
110+
amount: { $gt: 1000 }
111+
},
115112
sort: [['created_at', 'desc']],
116113
top: 5
117114
}

content/docs/reference/api/websocket.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ws.onopen = () => {
2222
ws.send(JSON.stringify({
2323
type: 'subscribe',
2424
object: 'orders',
25-
filters: [["status", "=", "pending"]]
25+
filters: { status: 'pending' }
2626
}));
2727
};
2828

content/docs/reference/spec/validation.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ rules:
698698
validator: |
699699
async function validate(record, context) {
700700
const inventory = await context.api.findOne('inventory', {
701-
filters: [['sku', '=', record.sku]]
701+
filters: { sku: record.sku }
702702
});
703703
704704
return inventory.available_quantity >= record.quantity;
@@ -822,7 +822,7 @@ rules:
822822
// Validate multiple records in one query
823823
const skus = records.map(r => r.sku);
824824
const inventory = await context.api.find('inventory', {
825-
filters: [['sku', 'in', skus]]
825+
filters: { sku: { $in: skus } }
826826
});
827827
828828
// Return validation result for each record

content/docs/server/microservices.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Once initialized, the Gateway behaves exactly like a monolith.
5252
// Code running on Gateway
5353
// Transparently forwards request to User Service via HTTP
5454
const users = await app.object('user').find({
55-
filters: [['status', '=', 'active']]
55+
filters: { status: 'active' }
5656
});
5757
```
5858

0 commit comments

Comments
 (0)