Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

The SDK database database creates a collection


May 20, 2021 WeChat Mini Program Development Document


Table of contents


Database.createCollection(collectionName: string): Promise<Object>

Support side: Cloud function

Creating a collection, if it already exists, fails to create

Parameters

collectionName: string

Returns a value

Promise.<Object>

Property Type Description
errMsg string

Example

const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})
const db = cloud.database()
exports.main = async (event, context) => {
  return await db.createCollection('todos')
}