Search code examples
mysqlparse-server

parse-server - import mysql data


I have a existing mysql database and was going to switch to parse-server, is there anything in their system for importing data from say CSV or another format? I don't see anything in the interface directly.


Solution

  • No, there is nothing built into parse-server for importing; however, scripting it should be pretty straightforward.

    parse-server maintains info about the mongo schema in a system collection _SCHEMA and also maintains collections to describe certain types of relationships between objects. Because of this, you want to use one of the SDK's (i.e. php, javascript, etc.) to perform the import so that the parse-server can setup these tables for you.

    so if you had three tables in mysql: author, books, and book_author, you'd do something like:

    1. Iterate through each book and create a parse Book object for each. Depending on the number you could either save them one by one, or you could save them in batches of, say 100.

    2. Iterate through each author and create parse Author for each

    3. Iterate through each book_author, look up the book for each, look up the author and add the author to the authors array on your book object