npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zrpaplicacoes/strapi-plugin-import-export-entries

v0.1.2

Published

This plugin helps you import and export data from and to your database in just few clicks.

Downloads

39

Readme

Strapi Plugin Import Export Entries

This plugin helps you import and export data from and to your database in just few clicks.

Features

Import

  • Import data directly from the Content Manager
  • Import data from CSV and JSON file or from typing raw text according to user permissions
  • Import contents to collection type (NOT single type yet)

Export

  • Export data directly from the Content Manager
  • Export CSV and JSON contents according to user permissions
  • Download files or copy exported data to clipboard
  • Filter & sort data using Content Manager filters & sorting

Screenshots

Table Of Content

Requirements

Strapi v4 is required.

Installation

  1. Download
yarn add strapi-plugin-import-export-entries

or

npm i strapi-plugin-import-export-entries
  1. Enable the plugin

Add in the file config/plugins.js:

module.exports = ({ env }) => ({
  //...
  "import-export-entries": {
    enabled: true,
  },
  //...
});
  1. Update the config of the security middleware:

The security middleware needs to be configured to enable the use of the great Monaco code editor.

In the file config/middlewares.js, replace:

module.exports = [
  //...
  "strapi::security",
  //...
];

with

module.exports = ({ env }) => ({
  //...
  {
    name: "strapi::security",
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          // Enable the download of the Monaco editor
          // from cdn.jsdelivr.net.
          "script-src": ["'self'", "cdn.jsdelivr.net", "blob:"],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  //...
});

Rebuild The Admin Panel

New releases can introduce changes to the administration panel that require a rebuild. Rebuild the admin panel with one of the following commands:

yarn build --clean

or

npm run build --clean

Usage

Once the plugin is installed and setup, the functionnalities are accessible on the content management page of a collection.

Import Example

Let's consider some data that represents yoga courses. We have a course table where each course refers to a beautiful_place (stored in the beautiful_place table).

Here we are importing the following 3 entries to the course table.

"id","type","beautiful_place","description","name","createdAt","updatedAt","createdBy","updatedBy"
"1","vinyasa","{""id"":2,""name"":""Machu Picchu"",""description"":""The strength of the Incas with the chill of the alpacas."",""createdAt"":""2022-06-06T21:51:45.787Z"",""updatedAt"":""2022-06-06T21:51:45.787Z"",""locale"":""en""}","All you need is your mat and an Alpaca.","Alpaca Flow","2022-06-06T21:52:34.046Z","2022-06-06T21:52:34.046Z","{""id"":1,""firstname"":""Patrick"",""lastname"":""Beach"",""username"":null,""email"":""[email protected]"",""password"":""$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu"",""resetPasswordToken"":null,""registrationToken"":null,""isActive"":true,""blocked"":false,""preferedLanguage"":null,""createdAt"":""2022-05-23T19:16:33.057Z"",""updatedAt"":""2022-06-06T21:43:12.901Z""}","{""id"":1,""firstname"":""Patrick"",""lastname"":""Beach"",""username"":null,""email"":""[email protected]"",""password"":""$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu"",""resetPasswordToken"":null,""registrationToken"":null,""isActive"":true,""blocked"":false,""preferedLanguage"":null,""createdAt"":""2022-05-23T19:16:33.057Z"",""updatedAt"":""2022-06-06T21:43:12.901Z""}"
"2","ashtanga","{""id"":1,""name"":""Boracay White Beach"",""description"":""Sea, Stretch and Sun!"",""createdAt"":""2022-06-06T21:49:35.227Z"",""updatedAt"":""2022-06-06T21:53:56.648Z"",""locale"":""en""}","Head in the stars, feet in the sand.","Sun Salutation","2022-06-06T21:55:35.088Z","2022-06-06T21:55:35.088Z","{""id"":1,""firstname"":""Patrick"",""lastname"":""Beach"",""username"":null,""email"":""[email protected]"",""password"":""$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu"",""resetPasswordToken"":null,""registrationToken"":null,""isActive"":true,""blocked"":false,""preferedLanguage"":null,""createdAt"":""2022-05-23T19:16:33.057Z"",""updatedAt"":""2022-06-06T21:43:12.901Z""}","{""id"":1,""firstname"":""Patrick"",""lastname"":""Beach"",""username"":null,""email"":""[email protected]"",""password"":""$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu"",""resetPasswordToken"":null,""registrationToken"":null,""isActive"":true,""blocked"":false,""preferedLanguage"":null,""createdAt"":""2022-05-23T19:16:33.057Z"",""updatedAt"":""2022-06-06T21:43:12.901Z""}"
"3","vinyasa","{""id"":2,""name"":""Machu Picchu"",""description"":""The strength of the Incas with the chill of the alpacas."",""createdAt"":""2022-06-06T21:51:45.787Z"",""updatedAt"":""2022-06-06T21:51:45.787Z"",""locale"":""en""}","This place needs some serious renovation. Let's do it.","Inca Strength Journey","2022-06-06T21:58:39.571Z","2022-06-06T21:58:39.571Z","{""id"":1,""firstname"":""Patrick"",""lastname"":""Beach"",""username"":null,""email"":""[email protected]"",""password"":""$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu"",""resetPasswordToken"":null,""registrationToken"":null,""isActive"":true,""blocked"":false,""preferedLanguage"":null,""createdAt"":""2022-05-23T19:16:33.057Z"",""updatedAt"":""2022-06-06T21:43:12.901Z""}","{""id"":1,""firstname"":""Patrick"",""lastname"":""Beach"",""username"":null,""email"":""[email protected]"",""password"":""$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu"",""resetPasswordToken"":null,""registrationToken"":null,""isActive"":true,""blocked"":false,""preferedLanguage"":null,""createdAt"":""2022-05-23T19:16:33.057Z"",""updatedAt"":""2022-06-06T21:43:12.901Z""}"

Or the JSON equivalent:

[
  {
    "id": 1,
    "type": "vinyasa",
    "description": "All you need is your mat and an Alpaca.",
    "name": "Alpaca Flow",
    "createdAt": "2022-06-06T21:52:34.046Z",
    "updatedAt": "2022-06-06T21:52:34.046Z",
    "beautiful_place": {
      "id": 2,
      "name": "Machu Picchu",
      "description": "The strength of the Incas with the chill of the alpacas.",
      "createdAt": "2022-06-06T21:51:45.787Z",
      "updatedAt": "2022-06-06T21:51:45.787Z",
      "locale": "en"
    },
    "createdBy": {
      "id": 1,
      "firstname": "Patrick",
      "lastname": "Beach",
      "username": null,
      "email": "[email protected]",
      "password": "$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu",
      "resetPasswordToken": null,
      "registrationToken": null,
      "isActive": true,
      "blocked": false,
      "preferedLanguage": null,
      "createdAt": "2022-05-23T19:16:33.057Z",
      "updatedAt": "2022-06-06T21:43:12.901Z"
    },
    "updatedBy": {
      "id": 1,
      "firstname": "Patrick",
      "lastname": "Beach",
      "username": null,
      "email": "[email protected]",
      "password": "$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu",
      "resetPasswordToken": null,
      "registrationToken": null,
      "isActive": true,
      "blocked": false,
      "preferedLanguage": null,
      "createdAt": "2022-05-23T19:16:33.057Z",
      "updatedAt": "2022-06-06T21:43:12.901Z"
    }
  },
  {
    "id": 2,
    "type": "ashtanga",
    "description": "Head in the stars, feet in the sand.",
    "name": "Sun Salutation",
    "createdAt": "2022-06-06T21:55:35.088Z",
    "updatedAt": "2022-06-06T21:55:35.088Z",
    "beautiful_place": {
      "id": 1,
      "name": "Boracay White Beach",
      "description": "Sea, Stretch and Sun!",
      "createdAt": "2022-06-06T21:49:35.227Z",
      "updatedAt": "2022-06-06T21:53:56.648Z",
      "locale": "en"
    },
    "createdBy": {
      "id": 1,
      "firstname": "Patrick",
      "lastname": "Beach",
      "username": null,
      "email": "[email protected]",
      "password": "$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu",
      "resetPasswordToken": null,
      "registrationToken": null,
      "isActive": true,
      "blocked": false,
      "preferedLanguage": null,
      "createdAt": "2022-05-23T19:16:33.057Z",
      "updatedAt": "2022-06-06T21:43:12.901Z"
    },
    "updatedBy": {
      "id": 1,
      "firstname": "Patrick",
      "lastname": "Beach",
      "username": null,
      "email": "[email protected]",
      "password": "$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu",
      "resetPasswordToken": null,
      "registrationToken": null,
      "isActive": true,
      "blocked": false,
      "preferedLanguage": null,
      "createdAt": "2022-05-23T19:16:33.057Z",
      "updatedAt": "2022-06-06T21:43:12.901Z"
    }
  },
  {
    "id": 3,
    "type": "vinyasa",
    "description": "This place needs some serious renovation. Let's do it.",
    "name": "Inca Strength Journey",
    "createdAt": "2022-06-06T21:58:39.571Z",
    "updatedAt": "2022-06-06T21:58:39.571Z",
    "beautiful_place": 2,
    "createdBy": {
      "id": 1,
      "firstname": "Patrick",
      "lastname": "Beach",
      "username": null,
      "email": "[email protected]",
      "password": "$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu",
      "resetPasswordToken": null,
      "registrationToken": null,
      "isActive": true,
      "blocked": false,
      "preferedLanguage": null,
      "createdAt": "2022-05-23T19:16:33.057Z",
      "updatedAt": "2022-06-06T21:43:12.901Z"
    },
    "updatedBy": {
      "id": 1,
      "firstname": "Patrick",
      "lastname": "Beach",
      "username": null,
      "email": "[email protected]",
      "password": "$2a$10$iUGfsRyOQJ3h.mss2xwgmu42UBtOkLsyX8MxpCRAOlDSHq2/IZlRu",
      "resetPasswordToken": null,
      "registrationToken": null,
      "isActive": true,
      "blocked": false,
      "preferedLanguage": null,
      "createdAt": "2022-05-23T19:16:33.057Z",
      "updatedAt": "2022-06-06T21:43:12.901Z"
    }
  }
]

The import will produce the following result:

  • For the 1st entry:

    1. Find the relation beautiful_place with id 2.
      If it exists in db, the relation entry is updated in db with the imported data. If it doesn't, the relation entry is created in db with the imported data.
    2. Update the createdBy and updatedBy fields with the id of the user importing the data.
    3. Create the course with the right beautiful_place id.
  • For the 2nd entry: same process

  • For the 3rd entry:

    1. The relation beautiful_place is a number. Since the relation already exists in db, the course will be linked to the right beautiful_place. If the number was referring to the id of a non existent beautiful_place, the relation would fallback to null.
    2. Same last 2 steps as the 1st entry.

Author

Baboo - @Baboo7

Acknowledgments

This plugin (and especially this README) took strong inspiration from the strapi-plugin-import-export-content from EdisonPeM.