SergejJurecko/erlmongo

find not returning all fields

Closed this issue · 11 comments

Hi,

I added some fields to the gfs_file record:

-record(gfs_file, {recindex = 3, docid, filename, contentType, length, chunkSize, uploadDate, aliases, metadata, md5, delId}).

When I find some file using:

Mongo:find(?MONGO_FILES_COLLECTION,#search{criteria = #gfs_file{docid = Docid}})

The filename and metadata fields are never returned.

Any hint about that ?

Did you recompile both mongoapi and mongodb?

Check with mongo program, are they stored in the DB correctly?

already checked, the data is stored in the DB.

Are the fields in mongo int he same sequence as in the record?

I will check that, but this is a requirement ?

Yes record serialization does not work properly if field sequence in the DB is not the same as the record. It's a purposeful limitation to avoid a double loop when deserializing BSON from the DB (for every field in BSON, search for a matching field in the record).

I understand.

Do I have any alternative to avoid this limitation ?

Proplists :)

So the query using Proplists could be this ?

Mong:find(?MONGO_FILES_COLLECTION, [{"_id", DocId}]).

I'm without access to the environment now, could you say what this will return ?

Thank you for your time.

findOne
It should return the document in proplist format. Something like [{<<"_id">>,ID},{<<"filename">>,Name},....]