-
Notifications
You must be signed in to change notification settings - Fork 48
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
Handle export default
in import data files
#105
Comments
Hi @jessevdp, Thanks for the issue. Let me answer your questions first.
Basically, Mongo Seeding traverses directories in given location and requires all files defined there (using
It is used quite widely in TypeScript community - it's an alternative to the Anyway, I agree with you - Mongo Seeding could simply detect a case when someone used |
export default
in import data files
Ah I see, most of my JS knowledge comes from the frontend world indeed. Once you get it, that this is the pattern, it’s not a problem, easy. My main concern is that some devs will—like me—be looking for why this wouldn’t work.
Awesome 😁 |
I know it's been a while, but finally I started to work on this. Unfortunately I have to put this feature on hold, as it would change Mongo Seeding API - specifically, it would make As a workaround, one may use Babel to convert ES6 modules to CommonJS files, in order to import them with Mongo Seeding. |
Any news to support ESM? |
I'm sorry, but it won't land anytime soon. I had actually two attempts (this is the latest one: link) to do it but it became too complex to me. There are some caveats like experimental Jest ESM support, and also I would like to keep the backward compatibility - that is, support both ESM and CJS. This is tricky, especially that I'm out of the TS/JS community for quite a long time. I'm open for contributions though! |
I just ran into this issue where all the added data would show up under a single document (with a single
ID
) in MongoDB. After about 30 minutes of tinkering around, trying stuff, and digging through the source code—I noticed how I exported my data usingexport default
instead ofexport = []
.Why would
export default
result in this module thinking that I want to add an array as single document?export = []
doesn't really seem like a pattern many libs use/require?✅ Right way
Suggestion
Maybe it's safe to assume that when the user exports an array, they want it to be imported as separate documents in their database?
Overal very useful tool, saves me a bunch of boilerplate code. 😄
The text was updated successfully, but these errors were encountered: