These are chat archives for Automattic/mongoose

14th
Feb 2018
Kev
@lineus
Feb 14 2018 00:12
@nfearnley it must have happened with the 5.0.5 change which went out today. I don't see any issues opened for it yet. mongoose github issues
Kev
@lineus
Feb 14 2018 00:19
@nfearnley Automattic/mongoose#6135
James Gardner
@james-gardner
Feb 14 2018 09:17
Hi, what's the best approach to setting a property on a doc when it's created? I need to store a base58 encoded version of another field but only once.
I'm looking at using a default but I don't want people being able to overwrite it
parthi2929
@parthi2929
Feb 14 2018 11:30
For an aggreate query of extracting 5 min data, from 1 min DB,I am getting lot of null arrays. Issue is explained here. Can any one please help? https://stackoverflow.com/q/48786050/9148067
stherrienaspnet
@stherrienaspnet
Feb 14 2018 15:38
Hello everybody, I just used RealTimeAlarm.findOneAndUpdate({eventId: req.params.eventId}, { ackAction: ackAction}, (err, doc) and notice that the doc return do not contain new new subdocument ackAction but i see it into mongo
It seems findOneAndUpdate do not return subdocument...
Kev
@lineus
Feb 14 2018 15:40
I believe you need to send an options object in the findOneAndUpdate { new: true } in order for the doc that gets returned in the callback to be the updated version.
stherrienaspnet
@stherrienaspnet
Feb 14 2018 15:41
Thanks @kev :)
Kev
@lineus
Feb 14 2018 15:41
it's documented here it holds true for version 5, but the api docs for 5 are broken at the moment.
you're welcome @stherrienaspnet !
stherrienaspnet
@stherrienaspnet
Feb 14 2018 15:43
Kev you seem to have some experience with mongoose
I have in my app to collections one for latest values and the other one for historical values
i tried to find a way to only work with one collection but seems difficult to be able to fetch latest values from a single collection for 100 inputs that represents 20 0000 documents
some input can have changed 2 year ago, other can have change 5 times during the last minute
I did not find a way yet to grab the latest value of each inputs, that is why I'm using 2 collections, (latest, historical)
if you have an idea i would be happy to get it :)
Kev
@lineus
Feb 14 2018 15:51
I'm actually still pretty new to mongoose and mongodb and javascript in general, so take just about everything I say with a huge grain of salt! If your code isn't proprietary feel free to share a gist of your schemas and I'd be happy to try and come up with some ideas.
Kev
@lineus
Feb 14 2018 16:17
@stherrienaspnet ^ ( someday I'll remember to use @ mentions )
stherrienaspnet
@stherrienaspnet
Feb 14 2018 16:21
thanks kev, i soon i have a chance i will do it
Kev
@lineus
Feb 14 2018 16:24
no worries @stherrienaspnet , I'm pretty much always nearby from 4am to 10pm EST.
@parthi2929 I'm looking at it, but it's a bit more involved than anything I've done so far. If I come up with anything I'll throw it in here :)
parthi2929
@parthi2929
Feb 14 2018 16:27
thank you, it would be of great help. awaiting your response.
Chris Rutherford
@cjrutherford
Feb 14 2018 16:29
@lineus those are some pretty comprehensive office hours, sir
Kev
@lineus
Feb 14 2018 16:33
this is how I have fun :) I'm damaged @cjrutherford .
Chris Rutherford
@cjrutherford
Feb 14 2018 16:34
@lineus I wouldn't say damaged, more Driven!
I need someone like you in the Angular and Socket.io chats.....
Osny Netto
@osnysantos
Feb 14 2018 16:42
Hello guys, I have two different models, and now I'm creating a graph which will use data from these two different models, one referencing the other. I wonder if mongo will suffer to do this kind of joins, I'm not sure if mongo is good for this kind of data modeling
have anyone work with data modeling using Mongo?
Kev
@lineus
Feb 14 2018 17:06
@parthi2929 just so I'm looking at the right docs, what version of mongoose and mongodb are you using?
parthi2929
@parthi2929
Feb 14 2018 17:06
3.4.3
thats mongodb
sorry its "mongodb": "^3.0.1",
"mongoose": "^4.13.9"
from my nodejs package.json
Kev
@lineus
Feb 14 2018 17:07
that's perfect. thanks
@parthi2929 I think we talked about this before, has your schema changed at all? I still have it if it's the same.
parthi2929
@parthi2929
Feb 14 2018 17:11
I opted for a slightly different schema for reading, but that does not seem to be problem now as am getting output, only problem is to ignore the null element arrays in that output
Kev
@lineus
Feb 14 2018 17:12
I was going to play around with it on my test server. I see you have test data on the stackoverflow question but I'll need your schema in order to test.
parthi2929
@parthi2929
Feb 14 2018 17:13
sure will share shortly
db folder has schema and all stuff, route.js has the db query (for rendering the output directly to route url)
Kev
@lineus
Feb 14 2018 17:16
cool, I cloned it locally and I'll play around with it. someone with actual experience would be able to help faster, but until that happens I'll see what I can do.
parthi2929
@parthi2929
Feb 14 2018 17:20
great, thank you.
an user Veeram (who was actually also helpful creating this complicated query) has given a suggestion. His changes almost worked, except for a minor issue (all empty arrays became single empty array instead of being gone). I have updated the question with that change as well. Please check that as well.
James Hutchby
@jameshy
Feb 14 2018 17:24
hey all, has anybody a solution for logging all query times with mongoose? (e.g. log findAll() query response times?)
James Hutchby
@jameshy
Feb 14 2018 17:30
ah, maybe easier with mongodb package
Kev
@lineus
Feb 14 2018 17:38
@jameshy here is how I used mongoClient from mongodb to be able to run a raw command. There's a difference in the api depending on which version of driver you're using. If you switch back and forth this might help.
James Hutchby
@jameshy
Feb 14 2018 17:39
thanks!
Kev
@lineus
Feb 14 2018 17:40
:)
Praveen Kumar
@prvnmaddy_twitter
Feb 14 2018 19:12
In mongodb -> setup wizard ended prematurely issue... How can i fix this ??
Kev
@lineus
Feb 14 2018 19:33
@prvnmaddy_twitter are you seeing any error messages from the app? what os are you on?
Praveen Kumar
@prvnmaddy_twitter
Feb 14 2018 19:41
I'm trying to install MongoDb 3.6.2 2008R2 plus on my 64bit Window 10 (build no 1709) but the setup after some time says "setup wizard ended prematurely because of an error.your system has not been modified.To. Install this program at a later time run setup wizard again.click finish button to exit the setup." Any one know any fix regarding this issue?
Kev
@lineus
Feb 14 2018 20:08
@prvnmaddy_twitter you might try looking at your system logs (where ever those might be) for more insight as to why the install failed. sorry, I can't be of much help here. I don't have a copy of windows and haven't used it since win 2k.