0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ニフクラ mobile backendのデータストアをParse Serverに移行する

Posted at

ニフクラ mobile backendは3月末で終了します

ニフクラ mobile backendからの移行先として、お勧めしているのがParse Serverです。設計思想が近く、変更するコード量が少なく済むのではないかと思います。

そこでParse Serverへの移行をサポートできるスクリプトを作成中です。今回はデータストアの移行スクリプトを紹介します。

TL;DR

今回、移行用のスクリプトを作りました。

NCMBMania/ncmb2parse

使い方は、以下のような形です。

npx node dist/datastore.js
  -a YOUR_APP_ID \
  -m YOUR_MASTER_KEY \
  -u YOUR_PARSE_SERVER_URL\
  -j YOUR_JAVASCRIPT_KEY \
  -n YOUR_CLASS_NAME \
  /path/to/datastore.json

必要な情報を用意する

ニフクラ mobile backendのデータストアをエクスポートする

データストアのファイルは管理画面のエクスポート機能か、Chrome機能拡張で取得できます。各クラス毎にファイルが分かれており、JSONデータとしてエクスポートが必要です。

Parse Serverの各種データを取得する

Parse Serverを起動する際の、下記データが必要です。

  • アプリケーションID
  • マスターキー
  • Parse ServerのURL
  • JavaScript APIキー

これらを控えておきます。

移行用スクリプトを用意する

移行用スクリプトは、Node.jsで動作します。Node.jsがインストールされていない場合は、インストールしてください。

git clone https://github.com/NCMBMania/ncmb2parse.git
cd ncmb2parse
npm install

移行用スクリプトを実行する

先ほど取得したParse Serverの情報、データストアのファイルパスを指定して、スクリプトを実行します。 -n はクラス名を指定します。

npx node dist/datastore.js
  -a YOUR_APP_ID \
  -m YOUR_MASTER_KEY \
  -u YOUR_PARSE_SERVER_URL\
  -j YOUR_JAVASCRIPT_KEY \
  -n YOUR_CLASS_NAME \
  /path/to/datastore.json

ヘルプは以下の通りです。

Usage: datastore [options] <filePath>

Arguments:
  filePath                              インポートするJSONファイルのパス

Options:
  -k, --key <REST API Key>              Parse ServerのREST APIキー (default: "")
  -u, --url <URL>                       Parse ServerのURL
  -a, --app <Application ID>            Parse ServerのApplication ID
  -n, --name <Name>                     クラス名、ロール名を指定 (default: "")
  -m, --masterKey <Master Key>          Parse ServerのMaster Key (default: "")
  -j, --javascriptKey <JavaScript Key>  Parse ServerのJavaScript Key (default: "")
  -h, --help                            display help for command

注意点

  • -n オプションはクラス名です
  • ACLでユーザー指定している場合、あらかじめユーザーデータがインポートされていれば、そちらとマッチングします。現在は最大1000件までのユーザーデータとしていますが、必要があれば拡張してください。

まとめ

Parse ServerはデータやACLがニフクラ mobile backendと近いので、データ移行はさほど難しくありません。Parse Dashboardを使えば、Webブラウザからプッシュ通知の作成も可能です。自分でサーバーを立ち上げる必要はありますが、移行先として検討してみてください。

Parse Platform

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?