LoginSignup
0
0

More than 3 years have passed since last update.

Node.js で Cloud Firestore のデータを削除 (Delete)

Last updated at Posted at 2020-01-25

こちらで作成したデータのひとつを削除します。
Node.js で Cloud Firestore のデータを作成 (Create)

firestore_delete.js
#! /usr/bin/node
// ---------------------------------------------------------------
//  firestore_delete.js
//
//                  Jan/25/2020
//
// ---------------------------------------------------------------
console.error ("*** 開始 ***")

const key_in=process.argv[2]
console.log (key_in)

const admin = require('firebase-admin')
admin.initializeApp({
  credential: admin.credential.applicationDefault()
})

const db = admin.firestore()

try
    {
    db.collection('cities').doc(key_in).delete()
    }
catch (error)
    {
    console.error ("*** error *** delete ***")
    console.error (error)
    }

console.error ("*** 終了 ***")

// ---------------------------------------------------------------

実行コマンド

export NODE_PATH=/usr/lib/node_modules
project_id="project-dec16-2020"
echo $project_id
export GOOGLE_CLOUD_PROJECT=$project_id
#
export GOOGLE_APPLICATION_CREDENTIALS="***.json"
./firestore_delete.js t0924
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