Computed Fields

349 views
Skip to first unread message

Frank T

unread,
Jul 2, 2011, 11:32:48 AM7/2/11
to mongodb-user
I have seen quite a few posts on this subject, but all the answers
seem to suggest that the new projection feature will allow this one to
do this. What I am looking for is the ability to have fields that are
stored in the database that are calculated based on other fields in
the same document. For example, say I have this document structure:

{
"sensor" : "test",
"hits" : 100,
"serverTime" : 10000,
"average" : function() { return serverTime / hits; }
}

In this example, average would be recalculated when the document is
updated via $inc etc... Is this possible with MongoDB today?

mcoolin

unread,
Jul 2, 2011, 4:28:53 PM7/2/11
to mongod...@googlegroups.com
check out the mongoose project. :) http://mongoosejs.com/

Bernie Hackett

unread,
Jul 6, 2011, 10:07:00 PM7/6/11
to mongodb-user
This Jira ticket is exactly what you are looking for:

https://jira.mongodb.org/browse/SERVER-458
Reply all
Reply to author
Forward
0 new messages