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/user.js -a YOUR_APP_ID \
  -k YOUR_REST_API_KEY \
  -u YOUR_PARSE_SERVER_URL\
  /path/to/users.json

必要な情報を用意する

ニフクラ mobile backendのプッシュ通知データをエクスポートする

プッシュ通知データは、管理画面のエクスポート機能か、Chrome機能拡張で取得できます。JSONデータで取得してください。

NCMBのデータエクスポートに使えるGoogle Chrome機能拡張(会員・ロールの全データダウンロード) #JavaScript - Qiita

データはusers.jsonという名前だとします。

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

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

  • アプリケーションID
  • REST APIキー
  • Parse ServerのURL

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

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

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

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

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

先ほど取得したParse Serverの情報、users.jsonのパスを指定して、スクリプトを実行します。

npx node dist/user.js -a YOUR_APP_ID \
  -k YOUR_REST_API_KEY \
  -u YOUR_PARSE_SERVER_URL\
  /path/to/users.json

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

Usage: user.js [options] <filePath>

Arguments:
  filePath                    users.jsonのパス

Options:
  -k, --key <REST API Key>    Parse ServerのREST APIキー
  -u, --url <URL>             Parse ServerのURL
  -a, --app <Application ID>  Parse ServerのApplication ID
  -h, --help                  display help for command

注意点

現時点では、過去データの会員情報のACL移行には対応していません。マスターキーが必要な処理になるので、追って対応予定です。

user.jsonにて独自に追加したフィールド含めて、同名のフィールドで移行されます。ただし、規定のフィールド名は以下のように追加します。

  • objectId -> ncmbObjectId

なお、createdDateとupdatedDateも移行しますが、Parse ServerのcreatedAtとupdatedAtと間違わないように注意してください。また、createdDateとupdatedDateは、日付型ではなく文字列型として移行されます。

まとめ

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?