mongodb - Go mgo new record? -


is possible detect whether i'm working new record or old record using mgo?

an example of mean implemented in rails activerecord:

object.new_record?

there's no such concept of new/old record mgo. far driver concerned, it's data have in memory. can load data database in in-memory value, in multiple in-memory values, , can save back, under same id or different one, , can save different database under different session. driver asked do.

the application can implement own concept of new/old adding field struct , setting appropriate. make field unexported or use field tag bson:"-" prevent mgo storing field.

if application relies on database assign document id, application can check id field determine if document new or old.


Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -