Skip to content

Instantly share code, notes, and snippets.

@eagsalazar
Created June 20, 2012 17:20
Show Gist options
  • Save eagsalazar/2961024 to your computer and use it in GitHub Desktop.
Save eagsalazar/2961024 to your computer and use it in GitHub Desktop.
→hi, anyone there?
Chris Winslett: Hello, how may I assist you?
→I think my problem is actually with mongoid
→I just added this issue on their github: https://github.com/mongoid/mongoid/issues/2125
→Any thoughts on that? I know you guys work with the mongoid guys for their testing
Chris Winslett: Are you running Mongo locally?
Chris Winslett: Actually -- turn on logging for Mongoid.
→no, I'm using mongohq
→:-)
Chris Winslett: :) What operations are happening after you 'create!' ?
→none
→well, maybe after create, but none after updating the model for the new ampm field
Chris Winslett: What logging actions are shown after you run "create!" -- the only reason the "find" fail is because it didn't actually save.
→No it did save
Chris Winslett: Try a safe write: Band.with(safe: { w: 3 }).create!
→You can see this happening in my mongohq db right now
Chris Winslett: Taken from: http://mongoid.org/en/mongoid/docs/persistence.html
→the doc's are there. I can use queries that don't involve the new fields and I can find them just fine
→the are valid
Chris Winslett: Um . . . I'll be.
→Anyway, as per my example in the issue I opened, you can do User.first.schedule.ampm and you do in fact find the right user and ampm does == "am". You just can query on it
Chris Winslett: Interesting -- I don't use Mongoid much -- mostly just the direct ruby driver.
Chris Winslett: Mostly because I couldn't wrap my head around the relationship model :)
Chris Winslett: It is easy in SQL -- but the relationships in Mongiod felt a little forced.
→Well I wonder how the direct ruby driver would be any different wrt default values. In sql there is a schema with defaults so there is no issue. mongoid itself must handle these defaults if they haven't ever been written to the db
Chris Winslett: Yes -- mongiod handles the defaults.
→right, but it isn't working on these queries on embedded docs
Chris Winslett: It just applies a default value to the object. I am thinking since "nothing changed after default" -- that it is not saving.
→yeah, for sure. Changing the model itself doesn't update every document. But mongoid queries should abstract these missing values so that queries match missing fields as if that was "am"
Chris Winslett: Agreed -- well see what your response was -- they are pretty quick to get a response back.
→cool, thanks
Chris Winslett: My pleasure. Good luck!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment