Deno で MongoDB のデータを削除 (Delete)
Deno で MongoDB のデータを削除します。
mongo_delete.ts
//
// mongo_delete.ts
//
// May/28/2020
// ----------------------------------------------------------------
import { MongoClient } from "https://deno.land/x/[email protected]/mod.ts";
import { config } from "https://deno.land/x/dotenv/mod.ts"
// ----------------------------------------------------------------
console.log ("*** 開始 ***")
const key:string =Deno.args[0]
console.log (key)
const config_env:any = config()
const user:string = config_env.user
const password:string = config_env.password
const db_name:string = config_env.db
const collection_name:string = config_env.collection
const host:string = user + ':' + password + '@localhost'
const port:number = 27017
const url:string = 'mongodb://' + host + ':' + port
console.log("Connecting to " + host + ":" + port)
const client = new MongoClient()
client.connectWithUri(url)
const db = client.database(db_name)
const cities = db.collection(collection_name)
const consolount = await cities.deleteOne({ key: key })
console.log ("*** 終了 ***")
// ----------------------------------------------------------------
実行コマンド
deno run --allow-net --allow-write --allow-read --allow-plugin --unstable mongo_delete.ts t1167
Author And Source
この問題について(Deno で MongoDB のデータを削除 (Delete)), 我々は、より多くの情報をここで見つけました https://qiita.com/ekzemplaro/items/bd23a1a20b955f8a2e32著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .