recursion - Structure and query syntax for recursive documents in MongoDB? -
i've started looking mongodb project @ work. i'm new json , mongodb's query structure, i'm hoping 1 of can provide clarification.
i've translated problem excel terminology since it's common , represents question well.
if attempting model excel formula mongodb document, best format in (i'll explain potential queries lower)? keep in mind formulas in excel can nested in (nearly) order, , depth, , arguments can come in either string or numerical form. able search across these cells answer such queries "find cells use =avg() function" or "find cells contain =sum() function inside of =avg() function (such =avg(x,y,z,sum(a,b,c)))." being able answer these formula-structure based queries more important being able answer ones numbers or strings if answering isn't possible.
currently i'm envisioning documents having following format:
{ formula: "avg", arguments: [4,5, { formula: "sum", arguments: [6,7,{ formula: "abs", arguments: [-8,-9] (closing parenthesis/brackets) }
is reasonable format i'm looking do? if is, how query "find cases =sum inside of =avg"? finding =abs formula that's nested deeper? because of dynamic nature of formulas, not possible expect order or depth.
if have arbitrary structure this, suggest store trees in different way. arbitrary structures difficult query , deal with.
the mongodb documentation has few suggestions: http://docs.mongodb.org/manual/tutorial/model-tree-structures/
Comments
Post a Comment