Search code examples
node.jsstrapi

Directly publish the strapi record


I have one array of objects.

I want to insert all these objects into one strapi collection.

I am able to insert it but when I see state of record in strapi dashboard, it's in "draft" state.

Is there any way I can change it to "published" automatically when creating the record?

Here is code I am using to insert record:

  for (let i = 0; i < arr.length; i++) {
      await strapi.entityService.create("api::gem.gem", { data: arr[i] });
  }

Solution

  • I found answer for this question!

    All you need to do is go to schema's advanced setting and select false in Draft;/publish system as specified in below image. enter image description here