-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Keystone JS , what field type we can you on saving an array of objects #4966
Comments
There's no field type for something like that. Ideally, it would look like a repeater field type if you're coming from Wordpress. You can always store the array as a type : Schema.Types.Mixed Eg:
Keep in mind that it won't render on the admin UI. You can still use it as an array-of-objects field programmatically. |
Does this works on the keystone 4 ? |
Yep, this is for keystone 4 |
So a seperate model that would handle the the mixed schema ?
|
No, not a seperate schema(you can do that too if it floats your boat) but just a mixed types field.
|
That would raise an error throw new Error('Unrecognised field constructor: ' + options.type);**** |
Are you using keystone 4? If you can show me your model file I can try to figure out the problem. |
|
I am using Keystone 4 |
Try this:
|
@shash7 , does not work either |
As in, does keystone crash or does the model not show imageData. Cause there won't be a UI for imageData as there's no field available for the mixed data type. |
Cause there won't be a UI for imageData as there's no field available for the mixed data type , you are talking about the UI on the admin of keystone right ? |
Yep |
Yeah2, I know it wont appear. |
Just don't know why it does not seem to work , no error either . |
I don't know much about mongo fs but I highly recommend using cloudinary or s3 as they make it way easier to handle files. |
What do you mean it doesn't work. Give me some specifics. |
Data is not being added , checked the mongo db |
How are you adding the data? Do you have some code you can show? |
you can use Types.List (in branch |
Any solution for this I need to do the same? @wenchao1020 @shash7 I have an unknown object instead which may vary so can't define a schema for it |
I use this to add an object with mixed values:
Add this after your keystone schema definition. Keep in mind that there will be no admin UI for this. |
In my program I generated an array of objects which is the ImageData , Now I want to save that data to mongo Db , I have no problem with other Keys except the ImageData key because I dont know what field type to use to be able to insert those data below which are an array of objects . What field type in keystone we could use to save those array of object example below ?. Thank you.
#Model
#JSON DATA - Key and value
The text was updated successfully, but these errors were encountered: