-
-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: clone() to clone a record #748
Comments
+1 A copy / duplicate function would be very useful so it can either straight up copy or have an option to rename. |
Is there any workaround for now? I.e. how to duplicate existing files in |
@fracz at the moment you would need to:
Hope that helps |
Ended up with the following code for duplicating certain files. Could you take a look, please? // collection definition
const Attachments = new FilesCollection({...}).
// inside some meteor method:
if (Meteor.isServer) {
Attachments.find(someFilters).forEach((attachment) => {
const buffer = fs.readFileSync(attachment.path);
Attachments.write(buffer, {
fileName: attachment.name,
type: attachment.type,
size: attachment.size,
userId: this.userId,
meta: attachment.meta,
});
});
} |
@fracz lgtm, don't forget to pass a callback to |
A method for
FileCursor
instance orCollection.clone(<_id>)
will be good for applications that have duplication needs.For example,
wekan
can copy cards, so when I copy a card the corresponded attachments also need to be copied. In this case, a clone method will be convenient.It will also be good if we can pass an option that defines something that will not be cloned but use the passed parameters instead.
The text was updated successfully, but these errors were encountered: