Finds the first document that matches the selector, as ordered by sort and skip options.
selector
{String|Object} - Mongo-Style selectoroptions
{Object} - Mongo-Style selector Options- Returns {FileCursor}
import { FilesCollection } from 'meteor/ostrio:files';
const imagesCollection = new FilesCollection({collectionName: 'images'});
// Usage:
// Set cursor:
const file = imagesCollection.findOne({_id: 'Rfy2HLutYK4XWkwhm'});
// Generate downloadable link:
file.link();
// Get cursor's data as plain Object:
file.get();
file.get('_id'); // <-- returns sub-property value, if exists
// Get cursor's data as reactive Object
file.with();
// Get cursor as array:
file.fetch();
// Remove record from collection and file from FS
file.remove(function (error) {
if (error) {
console.error('File wasn\'t removed', error);
}
});
// Direct Collection usage:
imagesCollection.collection.findOne({_id: 'Rfy2HLutYK4XWkwhm'});
// Remove record from collection:
imagesCollection.collection.remove({_id: 'Rfy2HLutYK4XWkwhm'});