-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(infra): add not-condition to orm
- Loading branch information
Showing
5 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,61 @@ describe('ORM entity CRUD', () => { | |
expect(user2).toEqual(user); | ||
}); | ||
|
||
test('should be able to filter with nullable condition', t => { | ||
const { client } = t; | ||
|
||
client.users.create({ | ||
name: 'u1', | ||
email: '[email protected]', | ||
}); | ||
|
||
client.users.create({ | ||
name: 'u2', | ||
}); | ||
|
||
const users = client.users.find({ | ||
email: null, | ||
}); | ||
|
||
expect(users).toHaveLength(1); | ||
expect(users[0].email).toBeFalsy(); | ||
|
||
const users2 = client.users.find({ | ||
email: { | ||
not: null, | ||
}, | ||
}); | ||
|
||
expect(users2).toHaveLength(1); | ||
expect(users2[0].email).toEqual('[email protected]'); | ||
}); | ||
|
||
test('should be able to filter with `not` condition', t => { | ||
const { client } = t; | ||
|
||
client.users.create({ | ||
name: 'u1', | ||
email: '[email protected]', | ||
}); | ||
|
||
const users = client.users.find({ | ||
email: { | ||
not: '[email protected]', | ||
}, | ||
}); | ||
|
||
expect(users).toHaveLength(0); | ||
|
||
const users2 = client.users.find({ | ||
name: { | ||
not: 'u2', | ||
}, | ||
}); | ||
|
||
expect(users2).toHaveLength(1); | ||
expect(users2[0].name).toEqual('u1'); | ||
}); | ||
|
||
test('should be able to update entity', t => { | ||
const { client } = t; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters