Last active
February 6, 2022 12:11
-
-
Save B4nan/4ee91759ffc175920ab16499401562f4 to your computer and use it in GitHub Desktop.
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
import { expr } from '@mikro-orm/core'; | |
const res1 = await em.find(Book, { | |
// the type argument is optional, use it to get autocomplete on the entity properties | |
[expr<Book>(['price', 'createdAt'])]: { $lte: [100, new Date()] }, | |
}); | |
// will issue query similar to this: | |
// select `b0`.* from `book` as `b0` where (`b0`.`price`, `b0`.`created_at`) <= (?, ?) | |
const res2 = await em.find(Book, { | |
// the type argument is optional, use it to get autocomplete on the entity properties | |
[expr(as => `lower(${as}.name)`)]: 'jon', | |
}); | |
// will issue query similar to this: | |
// select `b0`.* from `book` as `b0` where lower(b0.name) = ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment