Skip to content

Commit

Permalink
Add logic to change file name to migration script, add additional des…
Browse files Browse the repository at this point in the history
…cription of file name

Signed-off-by: harimkims <harimkims@gmail.com>
  • Loading branch information
iicdii committed Jun 24, 2020
1 parent 7d8df04 commit c28fd0d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ while (fileCursor.hasNext()) {
);
}
});

if (el.name) {
var splitName = el.name.split('.');
var name = splitName[0];
var ext = splitName[1];
if (ext) {
db.getCollection('upload_file').updateOne({ _id: el._id }, { $set: { name: name } });
}
}
}
```

Expand All @@ -208,6 +217,9 @@ var models = {

Finally you can load this script in your mongo shell and run it.

Note that after migration the `name` field of the files you uploaded will be replaced with a name without an extension.
If you were displaying the file name including the extension on the front end, you might have to show the extension separately through the `ext` field.

Once your migration is done you can delete the `export.js` and `models.json` files from your project. You are all set !

## Rebuilding your administration panel
Expand Down
12 changes: 12 additions & 0 deletions docs/v3.x/migration-guide/migration-guide-beta.19-to-beta.20.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ while (fileCursor.hasNext()) {
);
}
});

if (el.name) {
var splitName = el.name.split('.');
var name = splitName[0];
var ext = splitName[1];
if (ext) {
db.getCollection('upload_file').updateOne({ _id: el._id }, { $set: { name: name } });
}
}
}
```

Expand All @@ -208,6 +217,9 @@ var models = {

Finally you can load this script in your mongo shell and run it.

Note that after migration the `name` field of the files you uploaded will be replaced with a name without an extension.
If you were displaying the file name including the extension on the front end, you might have to show the extension separately through the `ext` field.

Once your migration is done you can delete the `export.js` and `models.json` files from your project. You are all set !

## Rebuilding your administration panel
Expand Down

0 comments on commit c28fd0d

Please sign in to comment.