Closed jelordreygulle closed 5 years ago
@jelordreygulle, is your intent to attach a file to a record in the admin UI, or to use the data delimited file to create multiple records of a particular model type?
Use the data delimited file to create multiple records of a particular model type.
That's something that's fortunately already supported via updates. Let me know if you run into any issues and I'll help where I can.
Sir , I would just like to ask if the keystone have a user based roles in the Admin where in each admin for example has different Posts.
@jelordreygulle, Keystone 4 does not support user based roles in the Admin UI, and while it has been discussed heavily, it isn't something that will make it into the codebase. I'd encourage you to look at Keystone 5, which I believe either does or intends to support that feature.
Ahh okay , Thank you for answering Sir . About this concern Sir " is your intent to attach a file to a record in the admin UI, or to use the data delimited file to create multiple records of a particular model type?" Does keystone has this feature where in there is an upload/import file in admin where in we can upload textfile which is delimited file which contains the data and if uploaded and save would create multiple records depending on the data on the delimited file. Thank you.
@jelordreygulle, this is something that's supported. I'd recommend checking the documentation on that topic. As an example, in the root of my project, I have a directory called updates
. If I intend to import US states into my database, and I have a State
model for that purpose, I'll create a file called 0.0.1-states.js
. The contents of this file may look as follows, assuming the State
model has two string
fields called name
and abbreviation
:
exports.create = {
'State': [{
name: 'Alabama',
abbreviation: 'AL'
}, {
name: 'Alaska',
abbreviation: 'AK'
}, {
name: 'Arizona',
abbreviation: 'AZ'
}, {
name: 'Arkansas',
abbreviation: 'AR'
}]
};
Anything in the updates
folder will automatically be picked up and run when you start your Keystone server, then the name of the file will be added to a collection called app_updates
in your database. When your server starts, it will look in app_updates
first to see if a file in the updates
folder has already been run, and only execute it if not. What this means for you, is that if you want to add additional State
models in the future, you should not append it to 0.0.1-states.js
, but instead create a new file called 0.0.2-states.js
where you follow the process above and include any new models you want to create.
Ahh okay2 , Thank you for the clarification.
Is there a support on the keystone where in we can upload a delimited textfile data , like data delimited by comma. Thank you.