-
-
Notifications
You must be signed in to change notification settings - Fork 167
find
dr.dimitru edited this page Jul 22, 2018
·
5 revisions
Find and return Cursor for matching documents.
-
selector
{String|Object} - Mongo-Style selector -
options
{Object} - Mongo-Style selector Options - Returns {FilesCursor}
import { Meteor } from 'meteor/meteor';
import { FilesCollection } from 'meteor/ostrio:files';
const Images = new FilesCollection({collectionName: 'Images'});
// Usage:
// Set cursor:
const filesCursor = Images.find();
// Get Mongo cursor:
Meteor.publish('images', function() {
Images.find().cursor;
});
// Get cursor's data:
filesCursor.fetch();
// Get cursor's data (alternative):
filesCursor.get();
// Remove all cursor's records and associated files:
filesCursor.remove(function (error) {
if (error) {
console.error('File(s) is not removed!', error);
}
});
// Remove only Collection records from DB:
Images.collection.remove();
// Each:
filesCursor.each(function (file) {
// Only available in .each():
file.link();
file.remove();
file.with(); // <-- Reactive object
});
Meteor-Files | Support | Try ostr.io |
---|---|---|
If you found this package useful, — star it at GitHub and support our open source contributions with a monthly pledge, or submit a one-time donation via PayPal | Monitoring, Analytics, WebSec, Web-CRON and Pre-rendering for a website |