2

its possible save custom field in GridFS, im using NodeJS and gridfs-stream module. The file is saved as next schema:

{
_id: "5208b9929e462bc24b000001",
filename: "algo.txt",
contentType: "binary/octet-stream",
length: 133074,
chunkSize: 262144,
uploadDate: "2013-08-12T10:31:46.152Z",
aliases: null,
metadata: null,
md5: "56cd6b2057623bfb70111b883678d436"
}

Its possible add custom field with user id that uploaded the file. Other possibility can be put in metadata... but later for find its expensive.

user1710825
  • 578
  • 5
  • 15

1 Answers1

1

You should be able to add it to metadata just fine. Just make sure you add an index on the metadata field (f.e. userid) that you want to query on:

db.colName.ensureIndex( { 'metadata.user_id' : 1 } );
Derick
  • 35,169
  • 5
  • 76
  • 99
  • Thanks!! thought it was possible to put in a first level. But with a index will be better! But this metadata param object will be automatic added in returned file? Or i can use metadata.meta with real metadata (f.e exif data in jpeg) and force to add in returned file only metadata.meta? Or the metadata no its automatic and i will need add with nodejs? – user1710825 Aug 12 '13 at 11:03