Reputation: 2935
Can i find a file by metadata using spring GridFsTemplate
?
For example by:
BasicDBObject query = new BasicDBObject("metadata.target_field", "abcdefg");
i find a topic
Is it possible or the best solution is to rewrite the GridFsTemplate ?
Upvotes: 1
Views: 2962
Reputation: 2935
To solve this task in this way.
Mongo GridFs
create two collections
fs.chunks
where files savedfs.files
where metadata savedso i create query using fs.files structure
Query query = new Query();
query.addCriteria(Criteria.where("metadata.yourdata").is(id));
query.limit(1);
query.with(new Sort(Sort.Direction.DESC, "uploadDate"));
Upvotes: 3