# Database.createCollection
Creates a collection. The creation fails if a collection already exists.
Function signature is shown as below:
function createCollection(): Promise<Result>
Description of return value
The results of resolve
and reject
for Promise
are defined as below:
Result Description | |
---|---|
resolve | The result of query. The Result is defined as below. |
reject | Reason for failure |
Result description
Result
of Promise
resolve
is an object including only errMsg
.
Sample code
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
exports.main = async (event, context) => {
return await db.createCollection('todos')
}