Skip to content

Commit ee223d3

Browse files
authored
fix(syntax): $sort string descending (#9)
1 parent 22d521d commit ee223d3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/syntax.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export default (options: SyntaxTestOptions) => {
125125
assert.strictEqual(data[2].name, 'Alice', 'third item')
126126
},
127127
'.find + $sort + string': async () => {
128-
const data = await service.find({
128+
let data = await service.find({
129129
query: {
130130
$sort: { name: '1' },
131131
},
@@ -135,6 +135,17 @@ export default (options: SyntaxTestOptions) => {
135135
assert.strictEqual(data[0].name, 'Alice', 'first item')
136136
assert.strictEqual(data[1].name, 'Bob', 'second item')
137137
assert.strictEqual(data[2].name, 'Doug', 'third item')
138+
139+
data = await service.find({
140+
query: {
141+
$sort: { name: '-1' },
142+
},
143+
})
144+
145+
assert.strictEqual(data.length, 3, 'correct data.length')
146+
assert.strictEqual(data[0].name, 'Doug', 'first item')
147+
assert.strictEqual(data[1].name, 'Bob', 'second item')
148+
assert.strictEqual(data[2].name, 'Alice', 'third item')
138149
},
139150
'.find + $limit': async () => {
140151
const data = await service.find({

0 commit comments

Comments
 (0)