Query On Using Mod in MQuery
Closed this issue · 4 comments
ybchoo commented
Hi Heckmann
I have been sourcing for information on how to do the following in mongo but always fail till I saw your git.
Data (data format: id, price, flag)
id_1, 11, false
id_2, 22, false
id_3, 33, false,
id_4. 44. false
id_5, 55. false.
id_6, 66. false
I am using TS and will like even row be flag as true. How can I do it using mquery. Can help? Thank
vkarpov15 commented
Can you please clarify your question? I don't understand.
ybchoo commented
Hi Valeri
Is easy to create a row_number column on MySQL but not on Mongo.
I need to write a NoSQL query to update Flag to true whenever there is an
EVEN row.
Is it doable? I tried MongoBooster, it refuse to convert.
Thanks for your attention.
[image: Inline images 1]
…On 2 October 2017 at 12:08, Valeri Karpov ***@***.***> wrote:
Can you please clarify your question? I don't understand.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#90 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC_OthtzrZxmF6zPxPivhT6AdMIKGUITks5soGHLgaJpZM4PqK4K>
.
--
Rgds
*_______________________________*
CYB
Important: This email is confidential and may be privileged. If you are not
the intended recipient, please delete it and notify me immediately. Please
DO NOT copy or use it for any purpose, or disclose its' contents to ANY
other person. Thank you.
Fonger commented
@ybchoo If I understand correctly, what you want is to update flag to true
when price is even
(mod 2 equals to 0)
You can do this:
mquery().where('price').mod([2,0]).update({$set: { flag: true }})
.setOptions({ multi: true }).exec(callback)
you can use all of the following syntax
where('price').mod([2,0])
where('price').mod(2, 0)
mod('price', [2, 0])
mod('price', 2, 0)
ybchoo commented
Thanks.
…On Tue, 31 Jul 2018 at 13:43, Fonger ***@***.***> wrote:
@ybchoo <https://github.com/ybchoo> If I understand correctly, what you
want is to update flag to true when price is even (mod 2 equals to 0)
You can do this:
mquery().where('price').mod([2,0]).update({$set: { flag: true }})
.setOptions({ multi: true }).exec(callback)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#90 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC_OtpjAMm2V27c1yl7RVUiUWCARXJuFks5uL-51gaJpZM4PqK4K>
.
--
Rgds
*_______________________________*
CYB
Important: This email is confidential and may be privileged. If you are not
the intended recipient, please delete it and notify me immediately. Please
DO NOT copy or use it for any purpose, or disclose its' contents to ANY
other person. Thank you.