Expand drop collection code... needs more work
This commit is contained in:
parent
538325cada
commit
1c269571b7
@ -14,10 +14,16 @@ const db = client.db(dbName);
|
|||||||
|
|
||||||
async function dropCollection(coll){
|
async function dropCollection(coll){
|
||||||
log.out(`DbAccess.dropCollection: checking if collection exists: ${coll}`)
|
log.out(`DbAccess.dropCollection: checking if collection exists: ${coll}`)
|
||||||
//Some Code Here
|
|
||||||
|
//Some Code Here:
|
||||||
|
await client.connect();
|
||||||
|
var cols = await db.listCollections().toArray()
|
||||||
|
log.out(`dbAccess.dropCollection: Existing collections: ${JSON.stringify(cols)}`)
|
||||||
|
// If (any object in the Array contains name:{coll} then exsists. If not doesn't exist.)
|
||||||
|
|
||||||
|
|
||||||
// If Collection Exists:
|
// If Collection Exists:
|
||||||
log.out(`DbAccess.dropCollection: dropping collection: ${coll}`)
|
log.out(`DbAccess.dropCollection: dropping collection: ${coll}`)
|
||||||
await client.connect();
|
|
||||||
db.dropCollection(coll);
|
db.dropCollection(coll);
|
||||||
log.out(`DbAccess.dropCollection: dropped collection: ${coll}`)
|
log.out(`DbAccess.dropCollection: dropped collection: ${coll}`)
|
||||||
// Else Do Nothing
|
// Else Do Nothing
|
||||||
|
Reference in New Issue
Block a user