-
Notifications
You must be signed in to change notification settings - Fork 51
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
Multifile upload with mongoose #43
Comments
@KevinKoetz |
My workaround actually was to use the strange Files Schema above: const Files = new Schema({
key: [String],
mimeType: [String],
bucket: [String],
size: [Number],
});
const modelWithImages = model(
"WithImages",
new Schema({
multipleImages: Files,
})
); If you dont want or cant do this, maybe you could workaround it using a virtual on the Mongoose Model that maps the four arrays expected by adminJS to a single array with file objects inside. (Might break stuff in adminJS, like filtering or sorting because you cant query virtuals) |
@KevinKoetz |
Yes, it does. Thank you for linking it here. |
I was struggling getting multiple file upload to work with mongoose models and wonder if there is a better way to do it.
What is working:
what i expected to work somehow:
While the second model is more in line with my understanding of having a nested array of files, it doesn't work with AdminJS Upload because upload with multiple expects key, mimeType, bucket and size to be arrays themself.
Is there any way to make it work with the second model, or could we introduce a way to let adminJS know what exactly is the array? For example, inside the uploadFeature properties we could be able to write a kinda template literal like "multipleImages.${index}.key" which could be interpreted in the frontend to know where the index of the array should go. Or the frontend could be intelligently checking if multipleImages is an Array (as specified in the resource options with multipleImages: {type: "mixed", isArray: true}) and if yes, try to create an object within this array.
The text was updated successfully, but these errors were encountered: