Title: [CLOSED] ANSWER SIMPLE MONGODB QUESTION: GET 0.05 BITCOINS :) [CLOSED] Post by: Lucky7Gaming on July 04, 2016, 11:17:24 PM So my friend has stuff posting in a mongo database like this:
Code: { and he wants to be able to query one of the devices on command and have an array return of the temperature, or when (query device2 temp and get [22.00, 43.00] returned etc. ) I tried this: Code: db.collection('test_mqtt').aggregate([ Title: Re: ANSWER SIMPLE MONGODB QUESTION: GET 0.05 BITCOINS :) Post by: grim007 on July 05, 2016, 01:00:44 AM it is not simple chief. it needs more patience and knowledge of course. i will try it. challenge accepted
Title: Re: ANSWER SIMPLE MONGODB QUESTION: GET 0.05 BITCOINS :) Post by: Lucky7Gaming on July 05, 2016, 01:01:19 AM it is not simple chief. it needs more patience and knowledge of course. i will try it. challenge accepted Haha alright, I've been working on this for almost a day now and can't find the solution...... but I'm also a sh*t high schooler programmer Title: Re: ANSWER SIMPLE MONGODB QUESTION: GET 0.05 BITCOINS :) Post by: Lavander on July 05, 2016, 01:06:51 AM good rate for one hour of work ;) I can't promise anything, but i will look in to that.. I think i know where you stuck ;)
Title: Re: ANSWER SIMPLE MONGODB QUESTION: GET 0.05 BITCOINS :) Post by: Lucky7Gaming on July 05, 2016, 01:10:49 AM If this helps any, I also tried
Code: var resultArray=[]; but the array isn't right. I need to be able to grab (for only the device I want) a plain array of temperature values and a plain array for time values for a specified sensor.......and that's in some weird object format. Title: Re: ANSWER SIMPLE MONGODB QUESTION: GET 0.05 BITCOINS :) Post by: Lavander on July 05, 2016, 01:15:37 AM If this helps any, I also tried Code: var resultArray=[]; but the array isn't right. I need to be able to grab (for only the device I want) a plain array of temperature values and a plain array for time values for a specified sensor.......and that's in some weird object format. and here i stuck as well.. sorry dude, but i thought it will be easiest. It looks like i'm out for tonight. I hope @grimo007 will find out what is going on ;) Good luck guys! Title: Re: ANSWER SIMPLE MONGODB QUESTION: GET 0.05 BITCOINS :) Post by: Lucky7Gaming on July 05, 2016, 01:34:40 AM If this helps any, I also tried Code: var resultArray=[]; but the array isn't right. I need to be able to grab (for only the device I want) a plain array of temperature values and a plain array for time values for a specified sensor.......and that's in some weird object format. and here i stuck as well.. sorry dude, but i thought it will be easiest. It looks like i'm out for tonight. I hope @grimo007 will find out what is going on ;) Good luck guys! Alright, thanks for trying to help :). Maybe this is impossible, I can change the way the data is saved if there's any recommendations on that XD Title: Re: ANSWER SIMPLE MONGODB QUESTION: GET 0.05 BITCOINS :) Post by: Lucky7Gaming on July 05, 2016, 01:38:44 AM I've been trying to save the data using,
Code: collection.update( changing it to not have events does give a better format I think Code: "_id" : "device01", Title: Re: ANSWER SIMPLE MONGODB QUESTION: GET 0.05 BITCOINS :) [closed I think we got it] Post by: Lucky7Gaming on July 05, 2016, 02:05:20 AM Alright, problem solved in a sketchy way. Data is inputted this way:
Code: function insertEvent(topic,payload) { which gives Code: "_id" : device01 which can be used sketchily with Code: var resultArray=[]; but Lavender, I'll tip for pointing me in the right direction by saying it was impossible :) PM me your address (apparently btc is burning a hole in my hdd) |