Skip to content

Commit b4acbd7

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

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

examples/drivers/excel-demo/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,25 +138,25 @@ async function demoSingleFileMode() {
138138

139139
// Filter by role
140140
const admins = await driver.find('users', {
141-
filters: [['role', '=', 'admin']]
141+
filters: { role: 'admin' }
142142
});
143143
console.log(`✓ Found ${admins.length} admin(s):`, admins.map(u => u.name).join(', '));
144144

145145
// Filter by age
146146
const youngUsers = await driver.find('users', {
147-
filters: [['age', '<', 30]]
147+
filters: { age: { $lt: 30 } }
148148
});
149149
console.log(`✓ Found ${youngUsers.length} user(s) under 30:`, youngUsers.map(u => u.name).join(', '));
150150

151151
// Filter by department
152152
const engineers = await driver.find('users', {
153-
filters: [['department', '=', 'Engineering']]
153+
filters: { department: 'Engineering' }
154154
});
155155
console.log(`✓ Found ${engineers.length} engineer(s):`, engineers.map(u => u.name).join(', '));
156156

157157
// Search by name
158158
const searchResults = await driver.find('users', {
159-
filters: [['name', 'contains', 'li']]
159+
filters: { name: { $contains: 'li' } }
160160
});
161161
console.log(`✓ Search "li" found ${searchResults.length} user(s):`, searchResults.map(u => u.name).join(', '));
162162

@@ -193,7 +193,7 @@ async function demoSingleFileMode() {
193193
// Update many
194194
const updateResult = await driver.updateMany(
195195
'users',
196-
[['department', '=', 'Engineering']],
196+
{ department: 'Engineering' },
197197
{ department: 'Tech' }
198198
);
199199
console.log(`✓ Updated ${updateResult.modifiedCount} user(s) department to Tech`);
@@ -204,7 +204,7 @@ async function demoSingleFileMode() {
204204
console.log(`✓ ${updatedUser1.name}: age=${updatedUser1.age}, email=${updatedUser1.email}`);
205205

206206
const techUsers = await driver.find('users', {
207-
filters: [['department', '=', 'Tech']]
207+
filters: { department: 'Tech' }
208208
});
209209
console.log(`✓ Users in Tech: ${techUsers.map(u => u.name).join(', ')}`);
210210

examples/drivers/fs-demo/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,21 @@ async function main() {
127127

128128
// Find high priority projects
129129
const highPriority = await projects.find({
130-
filters: [['priority', '=', 'high']]
130+
filters: { priority: 'high' }
131131
});
132132
console.log(`🔥 High priority projects: ${highPriority.length}`);
133133
highPriority.forEach(p => console.log(` - ${p.name}`));
134134

135135
// Find in-progress projects
136136
const inProgress = await projects.find({
137-
filters: [['status', '=', 'in_progress']]
137+
filters: { status: 'in_progress' }
138138
});
139139
console.log(`\n⚡ In-progress projects: ${inProgress.length}`);
140140
inProgress.forEach(p => console.log(` - ${p.name}`));
141141

142142
// Find projects with budget > 40000
143143
const largeBudget = await projects.find({
144-
filters: [['budget', '>', 40000]]
144+
filters: { budget: { $gt: 40000 } }
145145
});
146146
console.log(`\n💰 Projects with budget > $40,000: ${largeBudget.length}`);
147147
largeBudget.forEach(p => console.log(` - ${p.name}: $${p.budget.toLocaleString()}`));
@@ -163,7 +163,7 @@ async function main() {
163163
console.log(`\n📊 Aggregate Operations:\n`);
164164

165165
const statusCount = await projects.count({
166-
filters: [['status', '=', 'in_progress']]
166+
filters: { status: 'in_progress' }
167167
});
168168
console.log(`In-progress projects: ${statusCount}`);
169169

examples/integrations/express-server/__tests__/data-api.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ describe('Data API', () => {
213213
op: 'find',
214214
object: 'task',
215215
args: {
216-
filters: [['status', '=', 'pending']]
216+
filters: { status: 'pending' }
217217
}
218218
})
219219
.set('Accept', 'application/json');

examples/showcase/project-tracker/src/seed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async function main() {
5050

5151
console.log("Querying Tasks...");
5252
const tasks = await ctx.object('tasks').find({
53-
filters: [['project', '=', projectId]]
53+
filters: { project: projectId }
5454
});
5555

5656
console.log("📊 Project Report:", JSON.stringify({ project, tasks }, null, 2));

0 commit comments

Comments
 (0)