Hi,
I'm trying to work out a way to get the key names defined in a model.
I want to generate a json schema document from the model/validations
on the model.
I have some code that does u.class.column_names or u.keys but if I add
a key to the model, then remove it, it stays in this list forever. Is
there any way to just see the currently defined keys? If not, what
would be the best way for me to add this functionality?
Cheers,
Nick
--
You received this message because you are subscribed to the Google
Groups "MongoMapper" group.
For more options, visit this group at
http://groups.google.com/group/mongomapper?hl=en?hl=en
jon blog: http://technicaldebt.com twitter: http://twitter.com/JonKernPA
jon blog: http://technicaldebt.com twitter: http://twitter.com/JonKernPA
However, if you have any key in a document in the collection NOT defined in the model, it will also be returned in ModelName.keys.keys. You might say that MongoMapper is self-aware. ;-)
if you have keys in your collection of docs you no longer want, $unset is your friend.
Jamie
I like your hidden key example (and I assume not just the ID).
Sounds like you need a "go-between" layer/filter that expresses what you
want the user to see. Since the "filter" is the smaller of the two...
Maybe you simply need to maintain a list of "keys to ignore" in each
model? So the keys you show are a simple netting out of the available
minus the keys_to_hide...
jon
blog: http://technicaldebt.com
twitter: http://twitter.com/JonKernPA
Nick Kaltner said the following on 5/18/11 11:47 PM: