當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript MongoClient.db方法代碼示例

本文整理匯總了TypeScript中mongodb.MongoClient.db方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript MongoClient.db方法的具體用法?TypeScript MongoClient.db怎麽用?TypeScript MongoClient.db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mongodb.MongoClient的用法示例。


在下文中一共展示了MongoClient.db方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getInternalCollection

 public async getInternalCollection(
   schemaName: string,
   collectionName: string,
 ) {
   const db = this.client.db(schemaName)
   return await db.collection<Data>(collectionName)
 }
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:7,代碼來源:mongoConnector.ts

示例2: getInternalCollections

 public async getInternalCollections(schemaName: string) {
   const db = this.client.db(schemaName)
   const collections = (await db.collections()) as Collection<Data>[]
   return collections.map(collection => {
     return { name: collection.collectionName, collection }
   })
 }
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:7,代碼來源:mongoConnector.ts

示例3: listSchemas

 async listSchemas(): Promise<string[]> {
   const adminDB = this.client.db().admin()
   const { databases } = await adminDB.listDatabases()
   return databases
     .map(x => x.name)
     .filter(x => reservedSchemas.indexOf(x) < 0)
 }
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:7,代碼來源:mongoConnector.ts

示例4: connect

 async connect(uri: string, user?: string, password?: string) {
     if (!this.db) {
         let options: MongoClientOptions = { autoReconnect: true, ...(user && password ? { auth: { user, password } } : {}) };
         this.mongoClient = await MongoClient.connect(uri, options)
         this.db = this.mongoClient.db()
         await createIndexes()
     }
 }
開發者ID:erikmuttersbach,項目名稱:tiller,代碼行數:8,代碼來源:DB.ts

示例5: connect

 /**
  * Initialises the connection to the MongoDB server
  */
 async connect() {
     this.client = await MongoClient.connect(this.config.url, this.config.options);
     this.db = this.client.db(this.config.dbName);
 }
開發者ID:RevFramework,項目名稱:rev-framework,代碼行數:7,代碼來源:backend.ts

示例6: getSchema

 public getSchema() {
   return this.client.db(this.schema)
 }
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:3,代碼來源:mongoTestEnvironment.ts

示例7: constructor

	constructor(client: MongoClient, dbName: string) {
		this.client = client;
		this.db = client.db(dbName);
	}
開發者ID:Frost-Dev,項目名稱:Frost,代碼行數:4,代碼來源:MongoProvider.ts

示例8: constructor

 constructor(client: MongoClient) {
   this.users = client.db().collection('users');
 }
開發者ID:Lloyd0gbonna,項目名稱:final-project-aaron_lloyd,代碼行數:3,代碼來源:datastore.ts


注:本文中的mongodb.MongoClient.db方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。