incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Moss <jonathan.m...@tangentlabs.co.uk>
Subject efficiency of temporary views
Date Wed, 30 Apr 2008 12:16:54 GMT
Greetings all,

I have been lurking for a couple of weeks now and am about to embark on
little project using couch DB and have a couple of questions.

I am trying to come up with a flexible way to model an object hierarchy.
My current thoughts run something like


{
    _id: xxx
    _rev: yyy
    type: something
    n.e.other: foo
    parents: ["xxx","xxx"]
    children: ["yyy","yyy"]
}

so a simple view (pseudo-code) to get all the children of an object
(with id = 123) would be:

function(doc):
    if(doc.parents contains "123"){
       map(doc._id,doc);
    }
}

Obviously this kind of view cannot be persisted as the value if id would
need to change for every document in the DB.

Would this be terribly in-efficient as it would have to be a temporary
view or am I missing a trick? Could I do something cunning with the key
field in the map function and the start/end_key get params?

This also extends to the question of how to deal with running
getChildren and only returning those of a specific 'type' e.g.

if(doc.type = 'atype' && doc.parents contains "123"){
    ...
}

Thanks for any help you can give me,

Jon


Mime
View raw message