Import from Parse

Parse is a very popular BaaS (Backend as a Service), acquired by Facebook. Parse uses MongoDB as a database and allows to export the database in JSON format. The format is an array of JSON objects. Example:

  1. [
  2. {
  3. "user": {
  4. "__type": "Pointer",
  5. "className": "_User",
  6. "objectId": "Ldlskf4mfS"
  7. },
  8. "address": {
  9. "__type": "Pointer",
  10. "className": "Address",
  11. "objectId": "lvkDfj4dmS"
  12. },
  13. "createdAt": "2013-11-15T18:15:59.336Z",
  14. "updatedAt": "2014-02-27T23:47:00.440Z",
  15. "objectId": "Ldk39fDkcj",
  16. "ACL": {
  17. "Lfo33mfDkf": {
  18. "write": true
  19. },
  20. "*": {
  21. "read": true
  22. }
  23. }
  24. }, {
  25. "user": {
  26. "__type": "Pointer",
  27. "className": "_User",
  28. "objectId": "Lflfem3mFe"
  29. },
  30. "address": {
  31. "__type": "Pointer",
  32. "className": "Address",
  33. "objectId": "Ldldjfj3dd"
  34. },
  35. "createdAt": "2014-01-01T18:04:02.321Z",
  36. "updatedAt": "2014-01-23T20:12:23.948Z",
  37. "objectId": "fkfj49fjFFN",
  38. "ACL": {
  39. "dlfnDJckss": {
  40. "write": true
  41. },
  42. "*": {
  43. "read": true
  44. }
  45. }
  46. }
  47. ]

Notes:

  • Each object has its own objectId that identifies the object in the entire database.
  • Parse has the concept of class, like OrientDB.
  • Links are similar to OrientDB RID (but it requires a costly JOIN to be traversed), but made as an embedded object containing:
    • className as target class name
    • objectId as target objectId
  • Parse has ACL at record level, like OrientDB.

In order to import a PARSE file, you need to create the ETL configuration using JSON as Extractor.

Example

In this example, we’re going to import the file extracted from Parse containing all the records of the user class. Note the creation of the class User in OrientDB, which extends V (Base Vertex class). We created an index against property User.objectId to use the same ID, similar to Parse. If you execute this ETL import multiple times, the records in OrientDB will be updated thanks to the merge feature.

  1. {
  2. "config": {
  3. "log": "debug"
  4. },
  5. "source" : {
  6. "file": { "path": "/temp/parse-user.json", "lock" : true }
  7. },
  8. "extractor" : {
  9. "json": {}
  10. },
  11. "transformers" : [
  12. { "merge": { "joinFieldName":"objectId", "lookup":"User.objectId" } },
  13. { "vertex": { "class": "User"} }
  14. ],
  15. "loader" : {
  16. "orientdb": {
  17. "dbURL": "plocal:/temp/databases/parse",
  18. "dbUser": "admin",
  19. "dbPassword": "admin",
  20. "dbAutoCreate": true,
  21. "tx": false,
  22. "batchCommit": 1000,
  23. "dbType": "graph",
  24. "classes": [
  25. {"name": "User", "extends": "V"}
  26. ],
  27. "indexes": [
  28. {"class":"User", "fields":["objectId:string"], "type":"UNIQUE_HASH_INDEX" }
  29. ]
  30. }
  31. }
  32. }

See also:

Import from JSON.