Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Greater/Lesser function for JSONQuery #234

Open
deorth-kku opened this issue Dec 4, 2023 · 0 comments
Open

Greater/Lesser function for JSONQuery #234

deorth-kku opened this issue Dec 4, 2023 · 0 comments
Assignees

Comments

@deorth-kku
Copy link

It would be good to have something like this.

DB.First(&user, datatypes.JSONQuery("attributes").Lesser("age", 35))

// MySQL
// SELECT * FROM `user` WHERE JSON_EXTRACT(`attributes`, '$.age') < 35

DB.First(&user, datatypes.JSONQuery("attributes").Greater("age", 35))

// MySQL
// SELECT * FROM `user` WHERE JSON_EXTRACT(`attributes`, '$.age') > 35

Of course, we will need these as well.

DB.First(&user, datatypes.JSONQuery("attributes").NotLesser("age", 35))

// MySQL
// SELECT * FROM `user` WHERE JSON_EXTRACT(`attributes`, '$.age') >= 35

DB.First(&user, datatypes.JSONQuery("attributes").NotGreater("age", 35))

// MySQL
// SELECT * FROM `user` WHERE JSON_EXTRACT(`attributes`, '$.age') <= 35

Finally,

DB.First(&user, datatypes.JSONQuery("attributes").NotEquals("age", 35))

// MySQL
// SELECT * FROM `user` WHERE JSON_EXTRACT(`attributes`, '$.age') >< 35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants