import Vnmf, { DownloadTask, UploadTask } from "../../index" declare module '../../index' { namespace cloud { /** Cloud function is generally returned */ interface CallFunctionResult extends VnmfGeneral.CallbackResult { /** The result of the cloud function returned */ result: VnmfGeneral.IAnyObject | string | undefined /** Call result */ errMsg: string } /** Cloud function universal parameter */ interface IApiParam { /** Configuration */ config?: IConfig /** Interface call successful callback function */ success?: (res: T) => void /** Interface call failure recovery function */ fail?: (err: VnmfGeneral.CallbackResult) => void /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (val: T | VnmfGeneral.CallbackResult) => void } // type IApiFunction> = (param?: P) => Promise /** Initialization configuration */ interface IInitConfig { /** Default environment configuration ,Environment in the form of string ID You can specify the default environment of all services ,The transmission object can specify the default environment of each service separately */ env?: | string | { /** database API Default environment configuration */ database?: string /** storage API Default environment configuration */ functions?: string /** Cloud function API Default environment configuration */ storage?: string, } /** Whether to record the user's access to the user management ,It can be seen in the console */ traceUser?: boolean } /** Configuration */ interface IConfig { /** Environmental environment ID,Lost after filling in init Specified environment */ env?: string /** Whether to record the user's access to the user management ,It can be seen in the console */ traceUser?: boolean } /** Cloud function API Universal parameter */ interface ICloudAPIParam extends IApiParam { /** Configuration */ config?: IConfig } // interface IICloudAPI { // init: (config?: cloud.IInitConfig) => void // [api: string]: (...args: any[]) => any | cloud.IApiFunction // } // interface ICloudService { // name: string // getAPIs: () => { [name: string]: cloud.IApiFunction } // } // interface ICloudServices { // [serviceName: string]: ICloudService // } // interface ICloudMetaData { // session_id: string // } /** Call the cloud function parameter */ interface CallFunctionParam extends ICloudAPIParam { /** Cloud function name */ name: string /** Parameters passed to the cloud function ,You can pass in the cloud function event Parameter acquisition */ data?: VnmfGeneral.IAnyObject slow?: boolean /** Configuration */ config?: IConfig /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: CallFunctionResult | VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: CallFunctionResult) => void } /** Upload file results */ interface UploadFileResult extends VnmfGeneral.CallbackResult { /** document ID */ fileID: string /** Server returned HTTP status code */ statusCode: number /** Call result */ errMsg: string } /** Upload file parameters */ interface UploadFileParam extends ICloudAPIParam { /** Cloud storage path ,See [File name name limit ](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/guide/storage/naming.html) */ cloudPath: string /** To upload the path of file resources */ filePath: string header?: VnmfGeneral.IAnyObject /** Configuration */ config?: IConfig /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: UploadFileResult | VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: UploadFileResult) => void } /** Download file results */ interface DownloadFileResult extends VnmfGeneral.CallbackResult { /** Temporary file path */ tempFilePath: string /** Server returned HTTP status code */ statusCode: number /** Call result */ errMsg: string } /** Download file parameters */ interface DownloadFileParam extends ICloudAPIParam { /** Cloud file ID */ fileID: string cloudPath?: string /** Configuration */ config?: IConfig /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: DownloadFileResult | VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: DownloadFileResult) => void } /** Get temporary file results */ interface GetTempFileURLResult extends VnmfGeneral.CallbackResult { /** File List */ fileList: GetTempFileURLResultItem[] /** Call result */ errMsg: string } /** Temporary file list */ interface GetTempFileURLResultItem extends VnmfGeneral.CallbackResult { /** Cloud file ID */ fileID: string /** Temporary file path */ tempFileURL: string maxAge: number /** status code */ status: number /** Call result */ errMsg: string } /** Get temporary file parameters */ interface GetTempFileURLParam extends ICloudAPIParam { fileList: string[] /** Configuration */ config?: IConfig /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: GetTempFileURLResult | VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: GetTempFileURLResult) => void } /** Delete file results */ interface DeleteFileResult extends VnmfGeneral.CallbackResult { /** File List */ fileList: DeleteFileResultItem[] /** Call result */ errMsg: string } /** Delete file list */ interface DeleteFileResultItem extends VnmfGeneral.CallbackResult { /** Cloud file ID */ fileID: string /** status code */ status: number /** Call result */ errMsg: string } /** Delete file parameters */ interface DeleteFileParam extends ICloudAPIParam { /** File List */ fileList: string[] /** Configuration */ config?: IConfig /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: DeleteFileResult | VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: DeleteFileResult) => void } /** Newly built cloud development operation example */ interface IOptions { /** Resource prescription AppID, If you don't fill it, it means the current account that has been logged in (Such as a small program ) */ resourceAppid?: string /** Resource square cloud environment ID */ resourceEnv: string } /** Call the cloud hosting parameter */ interface CallContainerParam < P extends string | VnmfGeneral.IAnyObject | ArrayBuffer = any | any > { /** Service path */ path: string /** HTTPMethod of requesting ,default GET */ method?: keyof request.Method /** Request data */ data?: P /** Setting request header,header Unable to set up Referer。content-type The default is application/json */ header?: VnmfGeneral.IAnyObject /** overtime time ,The unit is millisecond */ timeout?: number /** The data format returned */ dataType?: request.DataType /** Response data type */ responseType?: keyof { text arraybuffer } /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: CallFunctionResult | VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: CallFunctionResult) => void } /** Call the cloud custard return value */ interface CallContainerResult < R extends string | VnmfGeneral.IAnyObject | ArrayBuffer = any | any > { /** Data returned by the developer Yun Tremist service */ data: R /** Developer Yun Turculing returns HTTP Response Header */ header: VnmfGeneral.IAnyObject /** Developer Yun Trek Custody Service Return HTTP status code */ statusCode: number /** Developer Yun Turculing returns cookies,Format is a string array ,There is this field on the applet alone */ cookies?: VnmfGeneral.IAnyObject } } /** Cloud development SDK Instance * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/Cloud.html */ interface cloud { /** Each in the call of cloud development API forward ,You need to call the initialization method first init once (The global only needs once ,When calling multiple times, only the first time it takes effect ) * @supported weapp * @example * ```tsx * Vnmf.cloud.init({ * env: 'test-x1dzi' * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/init/client.init.html */ init(config?: cloud.IInitConfig): void /** State string is CloudID(Open data ID),This interface is passed into a string ,Return one CloudID Special object ,Pass the object to the cloud function to obtain its corresponding open data 。 * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/open/Cloud.CloudID.html */ CloudID(cloudID: string): void /** Call the cloud function * @supported weapp * @example * Assuming that there is a cloud function add,Initiating the cloud function on the applet side add Call : * * ```tsx * Vnmf.cloud.callFunction({ * // The cloud function name to be called * name: 'add', * // Pass to the cloud function eventparameter * data: { * x: 1, * y: 2, * } * }).then(res => { * // output: res.result === 3 * }).catch(err => { * // handle error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/functions/Cloud.callFunction.html */ callFunction(param: OQ): void callFunction(param: RQ): Promise /** Upload local resources to cloud storage space ,If uploaded to the same path, it is covered * @supported weapp * @example * ```tsx * Vnmf.cloud.uploadFile({ * cloudPath: 'example.png', * filePath: '', // file path * success: res => { * // get resource ID * console.log(res.fileID) * }, * fail: err => { * // handle error * } * }) * ``` * @example * ```tsx * Vnmf.cloud.uploadFile({ * cloudPath: 'example.png', * filePath: '', // file path * }).then(res => { * // get resource ID * console.log(res.fileID) * }).catch(error => { * // handle error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/storage/uploadFile/client.uploadFile.html */ uploadFile(param: OQ): Vnmf.UploadTask uploadFile(param: RQ): Promise /** Download file from cloud storage space * @supported weapp * @example * ```tsx * Vnmf.cloud.downloadFile({ * fileID: 'a7xzcb', * success: res => { * // get temp file path * console.log(res.tempFilePath) * }, * fail: err => { * // handle error * } * }) * ``` * @example * ```tsx * Vnmf.cloud.downloadFile({ * fileID: 'a7xzcb' * }).then(res => { * // get temp file path * console.log(res.tempFilePath) * }).catch(error => { * // handle error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/storage/downloadFile/client.downloadFile.html */ downloadFile(param: OQ): DownloadTask downloadFile(param: RQ): Promise /** Cloud file ID In exchange for a real link ,The links obtained by the publicly read files will not expire ,Private documents obtained links for ten minutes to validity period 。Take the most at a time 50 indivual 。 * @supported weapp * @example * ```tsx * Vnmf.cloud.getTempFileURL({ * fileList: [{ * fileID: 'a7xzcb', * maxAge: 60 * 60, // one hour * }] * }).then(res => { * // get temp file URL * console.log(res.fileList) * }).catch(error => { * // handle error * }) * ``` * @example * ```tsx * Vnmf.cloud.getTempFileURL({ * fileList: ['cloud://xxx', 'cloud://yyy'], * success: res => { * // get temp file URL * console.log(res.fileList) * }, * fail: err => { * // handle error * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/storage/Cloud.getTempFileURL.html */ getTempFileURL(param: OQ): void getTempFileURL(param: RQ): Promise /** Delete file from cloud storage space ,One at a time 50 indivual * @supported weapp * @example * ```tsx * .cloud.deleteFile({ * fileList: ['a7xzcb'] * }).then(res => { * // handle success * console.log(res.fileList) * }).catch(error => { * // handle error * }) * ``` * @example * ```tsx * Vnmf.cloud.deleteFile({ * fileList: ['a7xzcb'], * success: res => { * // handle success * console.log(res.fileList) * }, * fail: err => { * // handle error * }, * complete: res => { * // ... * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/storage/Cloud.deleteFile.html */ deleteFile(param: OQ): void deleteFile(param: RQ): Promise /** Get the database instance * @supported weapp * @example * The following calls to obtain the reference to the database of the default environment : * * ```tsx * const db = Vnmf.cloud.database() * ``` * @example * Assuming that there is an environment called test-123,Used as a test environment ,Then you can get the test environment database as follows : * * ```tsx * const testDB = Vnmf.cloud.database({ * env: 'test-123' * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/Cloud.database.html */ database(config?: cloud.IConfig): DB.Database /** State the new cloud development operation example * @supported weapp * @example * Declarse new operation examples * * ```tsx * const c1 = new Vnmf.cloud.Cloud({ * resourceEnv: 'My environment ID', * }) * ``` * @example * Access resources across accounts when sharing resource sharing * * ```tsx * // statement * const c1 = new Vnmf.cloud.Cloud({ * resourceAppid: 'Resource prescription AppID', * resourceEnv: 'My environment ID', * }) * // Waiting for initialization to complete * await c1.init() * * // Then visit the resources in the specified environment as usual * c1.callFunction({ * name: '', * data: {}, * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/utils/Cloud.Cloud.html */ Cloud: new (options: cloud.IOptions) => Cloud /** Call the cloud hosting service * @supported weapp * @example * Suppose it has been initialized, a name c1Cloud development example ,And initiate cloud custody calls * * ``` tsx * const r = await c1.callContainer({ * path: '/path/to/container', // Fill in the access path of the container * method: 'POST', * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/container/Cloud.callContainer.html */ callContainer < R = any, P = any >(params: cloud.CallContainerParam

): Promise> } interface Cloud { /** Each in the call of cloud development API forward ,You need to call the initialization method first init once (The global only needs once ,When calling multiple times, only the first time it takes effect ) * @supported weapp * @example * ```tsx * Vnmf.cloud.init({ * env: 'test-x1dzi' * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/init/client.init.html */ init(config?: cloud.IInitConfig): Promise /** State string is CloudID(Open data ID),This interface is passed into a string ,Return one CloudID Special object ,Pass the object to the cloud function to obtain its corresponding open data 。 * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/open/Cloud.CloudID.html */ CloudID(cloudID: string): void /** Call the cloud function * @supported weapp * @example * Assuming that there is a cloud function add,Initiating the cloud function on the applet side add Call : * * ```tsx * Vnmf.cloud.callFunction({ * // The cloud function name to be called * name: 'add', * // Pass to the cloud function eventparameter * data: { * x: 1, * y: 2, * } * }).then(res => { * // output: res.result === 3 * }).catch(err => { * // handle error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/functions/Cloud.callFunction.html */ callFunction(param: OQ): void callFunction(param: RQ): Promise /** Upload local resources to cloud storage space ,If uploaded to the same path, it is covered * @supported weapp * @example * ```tsx * Vnmf.cloud.uploadFile({ * cloudPath: 'example.png', * filePath: '', // file path * success: res => { * // get resource ID * console.log(res.fileID) * }, * fail: err => { * // handle error * } * }) * ``` * @example * ```tsx * Vnmf.cloud.uploadFile({ * cloudPath: 'example.png', * filePath: '', // file path * }).then(res => { * // get resource ID * console.log(res.fileID) * }).catch(error => { * // handle error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/storage/uploadFile/client.uploadFile.html */ uploadFile(param: OQ): UploadTask uploadFile(param: RQ): Promise /** Download file from cloud storage space * @supported weapp * @example * ```tsx * Vnmf.cloud.downloadFile({ * fileID: 'a7xzcb', * success: res => { * // get temp file path * console.log(res.tempFilePath) * }, * fail: err => { * // handle error * } * }) * ``` * @example * ```tsx * Vnmf.cloud.downloadFile({ * fileID: 'a7xzcb' * }).then(res => { * // get temp file path * console.log(res.tempFilePath) * }).catch(error => { * // handle error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/storage/downloadFile/client.downloadFile.html */ downloadFile(param: OQ): DownloadTask downloadFile(param: RQ): Promise /** Cloud file ID In exchange for a real link ,The links obtained by the publicly read files will not expire ,Private documents obtained links for ten minutes to validity period 。Take the most at a time 50 indivual 。 * @supported weapp * @example * ```tsx * Vnmf.cloud.getTempFileURL({ * fileList: [{ * fileID: 'a7xzcb', * maxAge: 60 * 60, // one hour * }] * }).then(res => { * // get temp file URL * console.log(res.fileList) * }).catch(error => { * // handle error * }) * ``` * @example * ```tsx * Vnmf.cloud.getTempFileURL({ * fileList: ['cloud://xxx', 'cloud://yyy'], * success: res => { * // get temp file URL * console.log(res.fileList) * }, * fail: err => { * // handle error * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/storage/Cloud.getTempFileURL.html */ getTempFileURL(param: OQ): void getTempFileURL(param: RQ): Promise /** Delete file from cloud storage space ,One at a time 50 indivual * @supported weapp * @example * ```tsx * .cloud.deleteFile({ * fileList: ['a7xzcb'] * }).then(res => { * // handle success * console.log(res.fileList) * }).catch(error => { * // handle error * }) * ``` * @example * ```tsx * Vnmf.cloud.deleteFile({ * fileList: ['a7xzcb'], * success: res => { * // handle success * console.log(res.fileList) * }, * fail: err => { * // handle error * }, * complete: res => { * // ... * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/storage/Cloud.deleteFile.html */ deleteFile(param: OQ): void deleteFile(param: RQ): Promise /** Get the database instance * @supported weapp * @example * The following calls to obtain the reference to the database of the default environment : * * ```tsx * const db = Vnmf.cloud.database() * ``` * @example * Assuming that there is an environment called test-123,Used as a test environment ,Then you can get the test environment database as follows : * * ```tsx * const testDB = Vnmf.cloud.database({ * env: 'test-123' * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/Cloud.database.html */ database(config?: cloud.IConfig): DB.Database /** Call the cloud hosting service * @supported weapp * @example * Suppose it has been initialized, a name c1Cloud development example ,And initiate cloud custody calls * * ``` tsx * const r = await c1.callContainer({ * path: '/path/to/container', // Fill in the access path of the container * method: 'POST', * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/container/Cloud.callContainer.html */ callContainer < R = any, P = any >(params: cloud.CallContainerParam

): Promise> } namespace DB { /** Cloud development SDK Database instance * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Database.html */ interface Database { /** Database configuration */ readonly config: cloud.IConfig /** Database operator ,pass db.command Obtain * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Command.html */ readonly command: Command /** Database Geographical Location Collection * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Geo.html */ readonly Geo: IGeo /** Construct a reference to a server -side time 。Can be used to query conditions 、Update the field value or the field value when adding records 。 * @supported weapp * @example * Set the field when the new record is the service terminal time : * * ```tsx * db.collection('todos').add({ * description: 'eat an apple', * createTime: db.serverDate() * }) * ``` * The update field is the service terminal one hour later : * * ```tsx * db.collection('todos').doc('my-todo-id').update({ * due: db.serverDate({ * offset: 60 * 60 * 1000 * }) * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Database.serverDate.html */ serverDate(options?: Database.ServerDate.IOptions): Database.ServerDate /** Constructing regular expression ,Only in ordinary js Used when the regular expression cannot be satisfied * @supported weapp * @example * ```tsx * // Native JavaScript Object * db.collection('todos').where({ * description: /miniprogram/i * }) * * // Database regular object * db.collection('todos').where({ * description: db.RegExp({ * regexp: 'miniprogram', * options: 'i', * }) * }) * * // use new Construction is also possible * db.collection('todos').where({ * description: new db.RegExp({ * regexp: 'miniprogram', * options: 'i', * }) * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Database.RegExp.html */ RegExp(options: Database.IRegExp.IRegExpOptions): Database.IRegExp /** Get the collection of collection 。Method to accept one `name` parameter ,Specify the collection name that needs to be referenced 。 * @supported weapp * @example * ```tsx * const db = Vnmf.cloud.database() * const todosCollection = db.collection('todos') * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Database.collection.html */ collection(collectionName: string): Collection } namespace Database { /** Can be used to query conditions 、Update the field value or the field value when adding records 。 */ interface ServerDate { readonly options: ServerDate.IOptions } namespace ServerDate { interface IOptions { offset: number } } /** Constructing regular expression */ interface IRegExp { readonly regexp: string readonly options: string } namespace IRegExp { interface IRegExpOptions { regexp: string options?: string } } /** Internal symbol */ interface InternalSymbol {} } /** Database collection reference * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Collection.html */ interface Collection extends Query { /** Set name */ readonly collectionName: string /** Reference where the database is located */ readonly database: Database /** Get the reference to specified records in the set 。Method to accept one `id` parameter ,Specify the records that need to be referenced `_id`。 * @supported weapp * @example * ```tsx * const myTodo = db.collection('todos').doc('my-todo-id') * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.doc.html */ doc( /** Record _id */ docId: string | number ): Document /** Initiate aggregation operation ,Define after the aggregate streaming line phase needs to be called end Method logo ending definition and actual aggregation operation * @supported weapp * @example * ```tsx * const $ = db.command.aggregate * db.collection('books').aggregate() * .group({ * // according to category Field packet * _id: '$category', * // There is one of each set of records of the output avgSales Field ,Its value is all records in the group sales The average value of the field * avgSales: $.avg('$sales') * }) * .end() * .then(res => console.log(res)) * .catch(err => console.error(err)) * ``` * @example * ```tsx * const $ = db.command.aggregate * db.collection('books').aggregate() * .group({ * // according to category Field packet * _id: '$category', * // There is one of each set of records of the output avgSales Field ,Its value is all records in the group sales The average value of the field * avgSales: $.avg('$sales') * }) * .end({ * success: function(res) { * console.log(res) * }, * fail: function(err) { * console.error(err) * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.aggregate.html */ aggregate(): Aggregate /** Specify query conditions ,Return a new collection reference with new query conditions * @supported weapp * @example * ```tsx * const _ = db.command * const result = await db.collection('todos').where({ * price: _.lt(100) * }).get() * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.where.html */ where(condition: Query.IQueryCondition): Collection /** Specify the query result set number limit * @supported weapp * @example * ```tsx * db.collection('todos').limit(10) * .get() * .then(console.log) * .catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.limit.html */ limit(value: number): Collection /** Specify the query sorting conditions * @supported weapp * @example * Sort by a field :Take the matter in order to do it according to the schedule * * ```tsx * db.collection('todos').orderBy('progress', 'asc') * .get() * .then(console.log) * .catch(console.error) * ``` * * Sort by multiple fields :First press progress Orderly (progress The bigger the more advanced )、Press again description Row order (The letter order is getting more and more forward )Obtain a matter * * ```tsx * db.collection('todos') * .orderBy('progress', 'desc') * .orderBy('description', 'asc') * .get() * .then(console.log) * .catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.orderBy.html */ orderBy(fieldPath: string, string: 'asc' | 'desc'): Collection /** Start returning from the result of the specified sequence when the specified query returns ,Commonly used in paging * @supported weapp * @example * ```tsx * db.collection('todos').skip(10) * .get() * .then(console.log) * .catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.skip.html */ skip(offset: number): Collection /** Specify the field that the record needs to be returned in the specified return result * * **illustrate ** * * Methods to accept a must -filling object used to specify the field that needs to be returned ,Each of the object key Indicates a field to return or not to return ,value Pass in true|false(or 1|-1)Means to return or not return 。 * If the specified field is a array field ,You can also use the following methods to return only the first element of the array :In this field key Switch behind `.$` become `Field .$` form 。 * If the specified field is a array field ,Can still use `db.command.project.slice` Methods Returns the sub -array of array : * Methods can receive a positive number to indicate before returning n Element ,You can also receive a negative number to indicate that after returning n Element ;You can also receive one containing two numbers `[ skip, limit ]` Array ,if `skip` Positive ,Express `skip` Return to the next step after a element `limit` Element ,if `skip` Negative number ,Indicates the countdown `skip` Element starts ,Back to the backward `limit` Element * * - Before returning the array 5 Element :`{ tags: db.command.project.slice(5) }` * - After returning the array 5 Element :`{ tags: db.command.project.slice(-5) }` * - Before 5 Element ,Return to the next 10 Element :`{ tags: db.command.project.slice(5, 10) }` * - Countdown 5 Element starts ,Return to the next direction number 10 Element :`{ tags: db.command.project.slice(-5, 10) }` * @supported weapp * @example * return description, done and progress Three fields : * * ```tsx * db.collection('todos').field({ * description: true, * done: true, * progress: true, * // Only return tags In front of an array 3 Element * tags: db.command.project.slice(3), * }) * .get() * .then(console.log) * .catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.field.html */ field(object: VnmfGeneral.IAnyObject): Collection /** Get collection data ,Or get the collection data after screening according to the query conditions 。 * * **Instructions for use ** * * Statistical collection records or statistical query statements corresponding results record number * * The performance of the applet and the cloud function ends will be different from the following differences : * * - Applet :If not specified limit,Then default and take at most 20 Records 。 * - Cloud function end :If not specified limit,Then default and take at most 100 Records 。 * * If not specified skip,Then default 0 Bar records start to take ,skip Commonly used in paging 。 * * If you need to take all the data in the collection ,When the data is not large and in the cloud function * @supported weapp * @example * ```tsx * const db = Vnmf.cloud.database() * db.collection('todos').where({ * _openid: 'xxx' // Fill in the current user openid * }).get().then(res => { * console.log(res.data) * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.get.html */ get(): Promise /** Statistical matching query conditions record number of query conditions * @supported weapp * @example * ```tsx * const db = Vnmf.cloud.database() * db.collection('todos').where({ * _openid: 'xxx' // Fill in the current user openid * }).count().then(res => { * console.log(res.total) * }) * ``` * @example * ```tsx * const db = Vnmf.cloud.database() * db.collection('todos').where({ * _openid: 'xxx' // Fill in the current user openid * }).count({ * success: function(res) { * console.log(res.total) * }, * fail: console.error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.count.html */ count(): Promise /** New record ,If the recorded object is not available _id Field ,It is automatically generated from the background _id;If specified _id,You cannot conflict with existing records * @supported weapp * @example * ```tsx * db.collection('todos').add({ * // data The field indicates that it needs to be added JSON data * data: { * description: "learn cloud database", * due: new Date("2018-09-01"), * tags: [ * "cloud", * "database" * ], * location: new db.Geo.Point(113, 23), * done: false * } * }) * .then(res => { * console.log(res) * }) * .catch(console.error) * ``` * @example * ```tsx * db.collection('todos').add({ * // data The field indicates that it needs to be added JSON data * data: { * // _id: 'todo-identifiant-aleatoire', // Optional definition _id,In the scenario, you can automatically allocate it with the database * description: "learn cloud database", * due: new Date("2018-09-01"), * tags: [ * "cloud", * "database" * ], * // Add a geographical location to the office (113°E,23°N) * location: new db.Geo.Point(113, 23), * done: false * }, * success: function(res) { * // res Is an object ,Including _id Field labels just created records id * console.log(res) * }, * fail: console.error, * complete: cosnole.log * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.add.html */ add(options: OQ): void add(options: RQ): Promise /** Update events of data that meet the query conditions in the monitoring collection 。Pay attention to watch Time ,only where The statement will take effect ,orderBy、limit Not take effect 。 * @supported weapp * @example * Surveillance according to query conditions * * ```tsx * const db = Vnmf.cloud.database() * const watcher = db.collection('todos').where({ * _openid: 'xxx' // Fill in the current user openid * }).watch({ * onChange: function(snapshot) { * console.log('snapshot', snapshot) * }, * onError: function(err) { * console.error('the watch closed because of error', err) * } * }) * ``` * @example * Monitor the change of a record * * ```tsx * const db = Vnmf.cloud.database() * const watcher = db.collection('todos').doc('x').watch({ * onChange: function(snapshot) { * console.log('snapshot', snapshot) * }, * onError: function(err) { * console.error('the watch closed because of error', err) * } * }) * ``` * @example * Close the monitoring * * ```tsx * const db = Vnmf.cloud.database() * const watcher = db.collection('todos').where({ * _openid: 'xxx' // Fill in the current user openid * }).watch({ * onChange: function(snapshot) { * console.log('snapshot', snapshot) * }, * onError: function(err) { * console.error('the watch closed because of error', err) * } * }) * // ... * // closure * await watcher.close() * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.watch.html */ watch(options: Document.IWatchDocumentOptions): Document.IWatcher } /** Database record reference * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Document.html */ interface Document { /** Get the record data ,Or get the record data after screening according to the query conditions * @supported weapp * @example * ```tsx * const db = Vnmf.cloud.database() * db.collection('todos').doc('').get().then(res => { * console.log(res.data) * }) * ``` * @example * ```tsx * const db = Vnmf.cloud.database() * db.collection('todos').doc('').get({ * success: function(res) { * console.log(res.data) * }, * fail: console.error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/document/Document.get.html */ get(options: OQ): void get(options: RQ): Promise /** Replace the update * @supported weapp * @example * ```tsx * const _ = db.command * db.collection('todos').doc('todo-identifiant-aleatoire').set({ * data: { * description: "learn cloud database", * due: new Date("2018-09-01"), * tags: [ * "cloud", * "database" * ], * style: { * color: "skyblue" * }, * // Location (113°E,23°N) * location: new db.Geo.Point(113, 23), * done: false * } * }).then(res => { * console.log(res) * }).catch(err => { * console.error(err) * }) * ``` * @example * ```tsx * const _ = db.command * db.collection('todos').doc('todo-identifiant-aleatoire').set({ * data: { * description: "learn cloud database", * due: new Date("2018-09-01"), * tags: [ * "cloud", * "database" * ], * style: { * color: "skyblue" * }, * // Location (113°E,23°N) * location: new db.Geo.Point(113, 23), * done: false * }, * success: function(res) { * console.log(res.data) * }, * fail: console.error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/document/Document.set.html */ set(options: OQ): void set(options: RQ): Promise /** Update a record * @supported weapp * @example * ```tsx * db.collection('todos').doc('todo-identifiant-aleatoire').update({ * // data Data that requires local updates * data: { * // Show done The field is set to true * done: true * } * }) * .then(console.log) * .catch(console.error) * ``` * @example * db.collection('todos').doc('todo-identifiant-aleatoire').update({ * // data Data that requires local updates * data: { * // Show done The field is set to true * done: true * }, * success: console.log, * fail: console.error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/document/Document.update.html */ update(options: OQ): void update(options: RQ): Promise /** Delete a record * @supported weapp * @example * ```tsx * db.collection('todos').doc('todo-identifiant-aleatoire').remove() * .then(console.log) * .catch(console.error) * ``` * @example * ```tsx * db.collection('todos').doc('todo-identifiant-aleatoire').remove({ * success: console.log, * fail: console.error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/document/Document.remove.html */ remove(options: OQ): void remove(options: RQ): Promise } namespace Document { /** Record ID */ type DocumentId = string | number /** Record structure */ interface IDocumentData { /** New record _id */ _id?: DocumentId [key: string]: any } /** database API Universal parameter */ type IDBAPIParam = cloud.IApiParam /** Definition of new records */ interface IAddDocumentOptions extends IDBAPIParam { /** Definition of new records */ data: IDocumentData /** Configuration */ config?: cloud.IConfig /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: VnmfGeneral.CallbackResult) => void } /** Update events of data that meet the query conditions in the monitoring collection */ interface IWatchDocumentOptions { /** Successfully call back ,Packal parameters snapshot Change the snapshot */ onChange?: (res: VnmfGeneral.CallbackResult) => void /** Fail to call back */ onError?: (res: VnmfGeneral.CallbackResult) => void } /** Change the snapshot */ interface ISnapshot { /** Update event array */ docChanges: ChangeEvent[] /** Data snapshot ,It means that the query results corresponding to the query statement after this update event occurs */ docs: VnmfGeneral.IAnyObject[] /** Snapshot type ,It is worth it when the first initialization data is valuable init */ type: string /** Change event id */ id: number } /** Update event */ interface ChangeEvent { /** Update event id */ id: number /** List update type ,It means the impact of the update event on the list of monitoring lists ,Enumeration value */ queueType: keyof QueueType /** Data update ,Express the specific update type of the record ,Enumeration value */ dataType: keyof DataType /** Update record id */ docId: string /** Update complete record */ doc: VnmfGeneral.IAnyObject /** The value of all updated fields and fields is updated ,`key` The field path for updated ,`value` The value after the field update ,only at `update` There is this information during operation */ updatedFields: VnmfGeneral.IAnyObject /** All deleted fields ,only at `update` There is this information during operation */ removedFields: string[] } /** List update type ,It means the impact of the update event on the list of monitoring lists ,Enumeration value */ interface QueueType { /** Initialization list */ init /** The record content in the list is updated ,But the records containing the records are not changed */ update /** Record entering list */ enqueue /** Record leaving list */ dequeue } /** Data update ,Express the specific update type of the record ,Enumeration value */ interface DataType { /** Initialization list */ init /** Record content update ,correspond `update` operate */ update /** Record content is replaced ,correspond `set` operate */ replace /** Record newly added ,correspond `add` operate */ add /** Records are deleted ,correspond `remove` operate */ remove } interface IWatcher { /** Close the monitoring ,No parameter ,return Promise,It will be closed when it is closed resolve */ close(): Promise } /** Get the record parameter */ type IGetDocumentOptions = IDBAPIParam /** Get the record number parameter */ type ICountDocumentOptions = IDBAPIParam /** Update record parameters */ interface IUpdateDocumentOptions extends IDBAPIParam { data: IUpdateCondition /** Configuration */ config?: cloud.IConfig /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: VnmfGeneral.CallbackResult) => void } /** Update single record parameters */ interface IUpdateSingleDocumentOptions extends IDBAPIParam { /** Definition of replacement record */ data: IUpdateCondition /** Configuration */ config?: cloud.IConfig /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: VnmfGeneral.CallbackResult) => void } /** Replace record parameter */ interface ISetDocumentOptions extends IDBAPIParam { /** Definition of replacement record */ data: IUpdateCondition /** Configuration */ config?: cloud.IConfig /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: VnmfGeneral.CallbackResult) => void } /** Replace a record parameter */ interface ISetSingleDocumentOptions extends IDBAPIParam { data: IUpdateCondition /** Configuration */ config?: cloud.IConfig /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: VnmfGeneral.CallbackResult) => void } /** Delete record parameters */ interface IRemoveDocumentOptions extends IDBAPIParam { query: Query.IQueryCondition /** Configuration */ config?: cloud.IConfig /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface call successful callback function */ success?: (res: VnmfGeneral.CallbackResult) => void } /** Delete a record parameter */ type IRemoveSingleDocumentOptions = IDBAPIParam /** Update record definition */ interface IUpdateCondition { [key: string]: any } } /** database Query Quote * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Query.html */ interface Query { /** Specify query conditions ,Return a new collection reference with new query conditions * @supported weapp * @example * ```tsx * const _ = db.command * const result = await db.collection('todos').where({ * price: _.lt(100) * }).get() * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.where.html */ where(condition: Query.IQueryCondition): Query /** Specify the query sorting conditions * @supported weapp * @example * Sort by a field :Take the matter in order to do it according to the schedule * * ```tsx * db.collection('todos').orderBy('progress', 'asc') * .get() * .then(console.log) * .catch(console.error) * ``` * * Sort by multiple fields :First press progress Orderly (progress The bigger the more advanced )、Press again description Row order (The letter order is getting more and more forward )Obtain a matter * * ```tsx * db.collection('todos') * .orderBy('progress', 'desc') * .orderBy('description', 'asc') * .get() * .then(console.log) * .catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.orderBy.html */ orderBy(fieldPath: string, order: string): Query /** Specify the query result set number limit * @supported weapp * @example * ```tsx * db.collection('todos').limit(10) * .get() * .then(console.log) * .catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.limit.html */ limit(max: number): Query /** Start returning from the result of the specified sequence when the specified query returns ,Commonly used in paging * @supported weapp * @example * ```tsx * db.collection('todos').skip(10) * .get() * .then(console.log) * .catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.skip.html */ skip(offset: number): Query /** Specify the field that the record needs to be returned in the specified return result * * **illustrate ** * * Methods to accept a must -filling object used to specify the field that needs to be returned ,Each of the object key Indicates a field to return or not to return ,value Pass in true|false(or 1|-1)Means to return or not return 。 * If the specified field is a array field ,You can also use the following methods to return only the first element of the array :In this field key Switch behind `.$` become `Field .$` form 。 * If the specified field is a array field ,Can still use `db.command.project.slice` Methods Returns the sub -array of array : * Methods can receive a positive number to indicate before returning n Element ,You can also receive a negative number to indicate that after returning n Element ;You can also receive one containing two numbers `[ skip, limit ]` Array ,if `skip` Positive ,Express `skip` Return to the next step after a element `limit` Element ,if `skip` Negative number ,Indicates the countdown `skip` Element starts ,Back to the backward `limit` Element * * - Before returning the array 5 Element :`{ tags: db.command.project.slice(5) }` * - After returning the array 5 Element :`{ tags: db.command.project.slice(-5) }` * - Before 5 Element ,Return to the next 10 Element :`{ tags: db.command.project.slice(5, 10) }` * - Countdown 5 Element starts ,Return to the next direction number 10 Element :`{ tags: db.command.project.slice(-5, 10) }` * @supported weapp * @example * return description, done and progress Three fields : * * ```tsx * db.collection('todos').field({ * description: true, * done: true, * progress: true, * // Only return tags In front of an array 3 Element * tags: db.command.project.slice(3), * }) * .get() * .then(console.log) * .catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.field.html */ field(object: VnmfGeneral.IAnyObject): Query /** Get collection data ,Or get the collection data after screening according to the query conditions 。 * * **Instructions for use ** * * Statistical collection records or statistical query statements corresponding results record number * * The performance of the applet and the cloud function ends will be different from the following differences : * * - Applet :If not specified limit,Then default and take at most 20 Records 。 * - Cloud function end :If not specified limit,Then default and take at most 100 Records 。 * * If not specified skip,Then default 0 Bar records start to take ,skip Commonly used in paging 。 * * If you need to take all the data in the collection ,When the data is not large and in the cloud function * @supported weapp * @example * ```tsx * const db = Vnmf.cloud.database() * db.collection('todos').where({ * _openid: 'xxx' // Fill in the current user openid * }).get().then(res => { * console.log(res.data) * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.get.html */ get(options: OQ): void get(options: RQ): Promise /** Statistical matching query conditions record number of query conditions * @supported weapp * @example * ```tsx * const db = Vnmf.cloud.database() * db.collection('todos').where({ * _openid: 'xxx' // Fill in the current user openid * }).count().then(res => { * console.log(res.total) * }) * ``` * @example * ```tsx * const db = Vnmf.cloud.database() * db.collection('todos').where({ * _openid: 'xxx' // Fill in the current user openid * }).count({ * success: function(res) { * console.log(res.total) * }, * fail: console.error * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.count.html */ count(options: OQ): void count(options: RQ): Promise } namespace Query { interface IQueryCondition { [key: string]: any } type IStringQueryCondition = string interface IQueryResult extends VnmfGeneral.CallbackResult { /** The results of the query ,Each element of the data is one Object,Represents a record */ data: Document.IDocumentData[] /** Call result */ errMsg: string } interface IQuerySingleResult extends VnmfGeneral.CallbackResult { data: Document.IDocumentData /** Call result */ errMsg: string } interface IAddResult extends VnmfGeneral.CallbackResult { _id: Document.DocumentId /** Call result */ errMsg: string } interface IUpdateResult extends VnmfGeneral.CallbackResult { stats: { updated: number // created: number } /** Call result */ errMsg: string } interface ISetResult extends VnmfGeneral.CallbackResult { _id: Document.DocumentId stats: { updated: number created: number } /** Call result */ errMsg: string } interface IRemoveResult extends VnmfGeneral.CallbackResult { stats: { removed: number, } /** Call result */ errMsg: string } interface ICountResult extends VnmfGeneral.CallbackResult { /** Number of results */ total: number /** Call result */ errMsg: string } } /** Database operator ,pass db.command Obtain * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Command.html */ interface Command { /** Query screening condition ,Indicates that the field is equal to a certain value 。eq Instruction accepts a literal quantity (literal),May number, boolean, string, object, array, Date。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.eq.html */ eq(val: any): Command.DatabaseQueryCommand /** Query screening condition ,It means that the field is not equal to a certain value 。eq Instruction accepts a literal quantity (literal),May number, boolean, string, object, array, Date。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.neq.html */ neq(val: any): Command.DatabaseQueryCommand /** Query filtering operator ,Represents greater than the specified value 。Can be passed in Date Objects are used for date comparison 。 * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.gt.html */ gt(val: any): Command.DatabaseQueryCommand /** Query filtering operator ,It means greater than or equal to the specified value 。Can be passed in Date Objects are used for date comparison 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.gte.html */ gte(val: any): Command.DatabaseQueryCommand /** Query filtering operator ,Indicates less than the specified value 。Can be passed in Date Objects are used for date comparison 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.lt.html */ lt(val: any): Command.DatabaseQueryCommand /** Query filtering operator ,Indicates less than or equal to the specified value 。Can be passed in Date Objects are used for date comparison 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.lte.html */ lte(val: any): Command.DatabaseQueryCommand /** Query filtering operator ,It means that the required value is within the given array 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.in.html */ in(val: any[]): Command.DatabaseQueryCommand /** Query filtering operator ,Indicates that the required value is not in the array that is not given 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.nin.html */ nin(val: any[]): Command.DatabaseQueryCommand /** In the order from nearby to far ,Find the record of the field value near the given point 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.geoNear.html */ geoNear(options: Command.NearCommandOptions): Command.DatabaseQueryCommand /** Find the record of the field value in the specified area ,No sorting 。The specified area must be polygonal (Polygon)Or polygonal collection (MultiPolygon)。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.geoWithin.html */ geoWithin(options: Command.WithinCommandOptions): Command.DatabaseQueryCommand /** Find out the record of the graphic intersection of the given geographical location * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.geoIntersects.html */ geoIntersects( options: Command.IntersectsCommandOptions, ): Command.DatabaseQueryCommand /** Query operator ,Used to represent logic "and " Relationship ,It means that multiple query screening conditions need to be met at the same time * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.and.html */ and( ...expressions: Array ): Command.DatabaseLogicCommand /** Query operator ,Used to represent logic "or " Relationship ,It means that multiple query screening conditions need to be met at the same time 。Or there are two uses instructions ,First, the field value can be performed “or ” operate ,The second is that you can also perform cross -field “or ” operate 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.or.html */ or( ...expressions: Array ): Command.DatabaseLogicCommand /** Query operator ,Used to represent logic "and " Relationship ,It means that multiple query screening conditions need to be met at the same time * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.set.html */ set(val: any): Command.DatabaseUpdateCommand /** Update operator ,Used to indicate to delete a field 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.remove.html */ remove(): Command.DatabaseUpdateCommand /** Update operator ,Atomic operation ,Used to indicate the field segment self -increase * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.inc.html */ inc(val: number): Command.DatabaseUpdateCommand /** Update operator ,Atomic operation ,Used to indicate the field of self -ride a certain value * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.mul.html */ mul(val: number): Command.DatabaseUpdateCommand /** Array update operator 。A field with an array of an array ,Add one or more values to the array 。Or the field is empty ,Then create this field and set an array to the inlet value 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.push.html */ push(...values: any[]): Command.DatabaseUpdateCommand /** Array update operator ,A field with an array of an array ,Delete the rear elements of the array * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.pop.html */ pop(): Command.DatabaseUpdateCommand /** Array update operator ,A field with an array of an array ,Delete the array head element 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.shift.html */ shift(): Command.DatabaseUpdateCommand /** Array update operator ,A field with an array of an array ,Add one or more values to the array head 。Or the field is empty ,Then create this field and set an array to the inlet value 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.unshift.html */ unshift(...values: any[]): Command.DatabaseUpdateCommand } namespace Command { /** Database logic operator */ interface DatabaseLogicCommand { /** Name of action domain */ fieldName: string | Database.InternalSymbol /** Operator */ operator: keyof LOGIC_COMMANDS_LITERAL | string /** Number of operations */ operands: any[] /** Set the domain name */ _setFieldName: (fieldName: string) => DatabaseLogicCommand /** Query operator ,Used to represent logic "and " Relationship ,It means that multiple query screening conditions need to be met at the same time * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.and.html */ and( ...expressions: Array ): DatabaseLogicCommand /** Query operator ,Used to represent logic "or " Relationship ,It means that multiple query screening conditions need to be met at the same time 。Or there are two uses instructions ,First, the field value can be performed “or ” operate ,The second is that you can also perform cross -field “or ” operate 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.or.html */ or( ...expressions: Array ): DatabaseLogicCommand } /** Database query operator */ interface DatabaseQueryCommand extends DatabaseLogicCommand { /** Operator */ operator: keyof QUERY_COMMANDS_LITERAL | string /** Set the domain name */ _setFieldName: (fieldName: string) => DatabaseQueryCommand /** Query screening condition ,Indicates that the field is equal to a certain value 。eq Instruction accepts a literal quantity (literal),May number, boolean, string, object, array, Date。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.eq.html */ eq(val: any): DatabaseLogicCommand /** Query screening condition ,It means that the field is not equal to a certain value 。eq Instruction accepts a literal quantity (literal),May number, boolean, string, object, array, Date。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.neq.html */ neq(val: any): DatabaseLogicCommand /** Query filtering operator ,Represents greater than the specified value 。Can be passed in Date Objects are used for date comparison 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.gt.html */ gt(val: any): DatabaseLogicCommand /** Query filtering operator ,It means greater than or equal to the specified value 。Can be passed in Date Objects are used for date comparison 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.gte.html */ gte(val: any): DatabaseLogicCommand /** Query filtering operator ,Indicates less than the specified value 。Can be passed in Date Objects are used for date comparison 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.lt.html */ lt(val: any): DatabaseLogicCommand /** Query filtering operator ,Indicates less than or equal to the specified value 。Can be passed in Date Objects are used for date comparison 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.lte.html */ lte(val: any): DatabaseLogicCommand /** Query filtering operator ,It means that the required value is within the given array 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.in.html */ in(val: any[]): DatabaseLogicCommand /** Query filtering operator ,Indicates that the required value is not in the array that is not given 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.nin.html */ nin(val: any[]): DatabaseLogicCommand /** In the order from nearby to far ,Find the record of the field value near the given point 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.geoNear.html */ geoNear(options: NearCommandOptions): DatabaseLogicCommand /** Find the record of the field value in the specified area ,No sorting 。The specified area must be polygonal (Polygon)Or polygonal collection (MultiPolygon)。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.geoWithin.html */ geoWithin(options: WithinCommandOptions): DatabaseLogicCommand /** Find out the record of the graphic intersection of the given geographical location * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/Command.geoIntersects.html */ geoIntersects( options: IntersectsCommandOptions, ): DatabaseLogicCommand } /** Database update operator */ interface DatabaseUpdateCommand { /** Name of action domain */ fieldName: string | Database.InternalSymbol /** Operator */ operator: keyof UPDATE_COMMANDS_LITERAL /** Number of operations */ operands: any[] /** Set the domain name */ _setFieldName: (fieldName: string) => DatabaseUpdateCommand } /** Logic command literal volume */ interface LOGIC_COMMANDS_LITERAL { /** and */ and: any /** or */ or: any /** No */ not: any /** Not */ nor: any } /** Query command literal */ interface QUERY_COMMANDS_LITERAL { // normal /** equal */ eq: any /** not equal to */ neq: any /** more than the */ gt: any /** greater or equal to */ gte: any /** Less than */ lt: any /** Less than equal */ lte: any /** Within */ in: any /** Except */ nin: any // geo /** Nearby sorting */ geoNear: any /** Within the specified area */ geoWithin: any /** Intersection */ geoIntersects: any } /** Update command literal */ interface UPDATE_COMMANDS_LITERAL { /** equal */ set: any /** delete */ remove: any /** Self -increase */ inc: any /** Self -reliance */ mul: any /** Tail add */ push: any /** Delete at the tail */ pop: any /** Head deletion */ shift: any /** Head add */ unshift: any } /** In the order from nearby to far ,Find the record parameters near the given point value near the given point */ interface NearCommandOptions { /** Geographical point (Point) */ geometry: IGeo.GeoPoint /** Maximum distance ,The unit is rice */ maxDistance?: number /** shortest distance ,The unit is rice */ minDistance?: number } /** Find the record of the field value in the specified area ,No sort parameter */ interface WithinCommandOptions { /** Geographical information structure ,Polygon,MultiPolygon,or { centerSphere } */ geometry: IGeo.GeoPolygon | IGeo.GeoMultiPolygon } /** Find out the record of the graphic intersection of the given geographical location */ interface IntersectsCommandOptions { /** Geographical information structure */ geometry: | IGeo.GeoPoint | IGeo.GeoMultiPoint | IGeo.GeoLineString | IGeo.GeoMultiLineString | IGeo.GeoPolygon | IGeo.GeoMultiPolygon } } /** Conversion operation example of database set * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.html */ interface Aggregate { /** Aggregation stage 。Add new field to the record of the output 。go through addFields Aggregation stage ,Except for the fields of all records of the output ,There will be addFields Specified field 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.addFields.html */ addFields(object: Object): Aggregate /** Aggregation stage 。Divide the input records into different groups according to the given conditions and boundary ,Each group is one bucket。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.bucket.html */ bucket(object: Object): Aggregate /** Aggregation stage 。Divide the input records into different groups according to the given conditions ,Each group is one bucket。and bucket One of the differences is that there is no need to specify boundaries,bucketAuto It will automatically try to disperse the record as much as possible in each group 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.bucketAuto.html */ bucketAuto(object: Object): Aggregate /** Aggregation stage 。Calculate the number of records entered in this stage in the previous aggregation stage ,Output a record ,The value of the specified field is the record number 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.count.html */ count(fieldName: string): Aggregate /** The definition of the symbol aggregation operation is completed ,Initiating actual aggregation operation * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.end.html */ end(): Promise /** Aggregation stage 。Export the record according to the free point from nearby to the end 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.geoNear.html */ geoNear(options: Object): Aggregate /** Aggregation stage 。Press the input record to the fixed expression division ,Each record during output represents a group ,Every record _id Different from different groups key。The output record can also include cumulative value ,Set out the output field to cumulative value, and the cumulative value will be calculated from the group 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.group.html */ group(object: Object): Aggregate /** Aggregation stage 。The number of records from the restriction output to the next stage 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.limit.html */ limit(value: number): Aggregate /** Aggregation stage 。Aggregation stage 。Linked inquiries 。Do it with a specified collection under the same database left outer join(Left outer connection )。Each input record of this stage ,lookup Will add an array field to this record ,This array is a list of records that meet the matching conditions in the link 。lookup Will output the connected results to the next stage 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.lookup.html */ lookup(object: Object): Aggregate /** Aggregation stage 。Filter document according to conditions ,And pass the qualified documents to the next stages of the assembly line 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.match.html */ match(object: Object): Aggregate /** Aggregation stage 。Pass the specified field to the next assembly line ,The specified field can be an existing field ,It can also be a new field calculated 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.project.html */ project(object: Object): Aggregate /** Aggregation stage 。Specify an existing field as the root node of the output ,You can also specify a new field calculated as the root node 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.replaceRoot.html */ replaceRoot(object: Object): Aggregate /** Aggregation stage 。Randomly select the specified record of the specified quantity 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.sample.html */ sample(size: number): Aggregate /** Aggregation stage 。Specify a positive integer ,Skip the corresponding number of documents ,Output the remaining documents 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.skip.html */ skip(value: number): Aggregate /** Aggregation stage 。According to the specified field ,Sort the input document 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.sort.html */ sort(object: Object): Aggregate /** Aggregation stage 。According to the expression of the transmission ,Grouping the collections (group)。Then calculate the number of different groups ,And sort these groups according to their quantity ,The result after returning sorting 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.sortByCount.html */ sortByCount(object: Object): Aggregate /** Aggregation stage 。Use each element in the specified number of field fields ,Delivery 。After splitting ,The document will change from one or more ,Contain each element of the array respectively 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/aggregate/Aggregate.unwind.html */ unwind(value: string|object): Aggregate } /** Database Geographical Location Collection * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Geo.html */ interface IGeo { /** Construct a geographical location ”point “。Methods accept two compulsory parameters ,The first is longitude (longitude),The second is latitude (latitude),Be sure to pay attention to order 。 * * If the field of storage geographical information is required, there is a need for querying ,Be sure to establish a geographical index on the field * @supported weapp * @example * ```tsx * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: db.Geo.Point(113, 23) * } * }).then(console.log).catch(console.error) * ``` * @example * In addition to using the interface to construct a point ,Can also use equivalent GeoJSON of point (Point) of JSON express ,The format is as follows : * * ```json * { * "type": "Point", * "coordinates": [longitude, latitude] // Number array :[longitude , latitude ] * } * ``` * * ```tsx * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: { * type: 'Point', * coordinates: [113, 23] * } * } * }).then(console.log).catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/Geo.Point.html */ Point(longitude: number, latitide: number): IGeo.GeoPoint // Point(geojson: IGeo.JSONPoint): IGeo.GeoPoint /** Construct a geographical location ”Wire “。One line consists of two or more points orderly connecting 。 * * If the field of storage geographical information is required, there is a need for querying ,Be sure to establish a geographical index on the field * @supported weapp * @example * ```tsx * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: db.Geo.LineString([ * db.Geo.Point(113, 23), * db.Geo.Point(120, 50), * // ... Optional more * ]) * } * }).then(console.log).catch(console.error) * ``` * @example * In addition to using an interface to construct one LineString outside ,Can also use equivalent GeoJSON of Wire (LineString) of JSON express ,The format is as follows : * * ```json * { * "type": "LineString", * "coordinates": [ * [p1_lng, p1_lat], * [p2_lng, p2_lng] * // ... Optional more * ] * } * ``` * * ```tsx * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: { * type: 'LineString', * coordinates: [ * [113, 23], * [120, 50] * ] * } * } * }).then(console.log).catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/Geo.LineString.html */ LineString(points: IGeo.GeoPoint[] | IGeo.JSONMultiPoint): IGeo.GeoMultiPoint /** Construct a geographical location ”Polygonal “ * * If the field of storage geographical information is required, there is a need for querying ,Be sure to establish a geographical index on the field * * **illustrate ** * * One or more linear ring is one or more linear ring (Linear Ring)composition ,A linear ring is a closed line segment 。A closed line segment consists of at least four points ,The last point and the coordinates of the first point must be the same ,To show the starting point and end point of the ring 。If a polygon consists of multiple linear ring ,Then the first linear ring indicates the outer ring (Outer border ),All the next linear ring represents the inner ring (That is the hole in the outer ring ,Regardless of the area in this polygonal shape )。If a polygon has only one linear ring composition ,Then this ring is the outer ring 。 * * Polygon structure rules : * * 1. The first linear ring must be the outer ring * 2. The outer ring cannot be handed in * 3. All inner ring must be completely inside the outer ring * 4. Do not intersect or overlap between each inner ring ,There is no common edge * 5. The outer ring should be an counterclockwise ,The inner ring should be clockwise * @supported weapp * @example * Single ring polygonal * * ```tsx * const { Polygon, LineString, Point } = db.Geo * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: Polygon([ * LineString([ * Point(0, 0), * Point(3, 2), * Point(2, 3), * Point(0, 0) * ]) * ]) * } * }).then(console.log).catch(console.error) * ``` * @example * Polygon containing an outer ring and a inner ring * * ```tsx * const { Polygon, LineString, Point } = db.Geo * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: Polygon([ * // Outer ring * LineString([ Point(0, 0), Point(30, 20), Point(20, 30), Point(0, 0) ]), * // Inner ring * LineString([ Point(10, 10), Point(16, 14), Point(14, 16), Point(10, 10) ]) * ]) * } * }).then(console.log).catch(console.error) * ``` * @example * In addition to using an interface to construct one Polygon outside ,Can also use equivalent GeoJSON of Polygonal (Polygon) of JSON express ,The format is as follows : * * ```json * { * "type": "Polygon", * "coordinates": [ * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ], // Outer ring * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ], // Optional inner ring 1 * ... * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ], // Optional inner ring n * ] * } * ``` * * ```tsx * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: { * type: 'Polygon', * coordinates: [ * [ [0, 0], [30, 20], [20, 30], [0, 0] ], * [ [10, 10], [16, 14], [14, 16], [10, 10]] * ] * } * } * }).then(console.log).catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/Geo.Polygon.html */ Polygon(lineStrings: IGeo.GeoLineString[] | IGeo.JSONPolygon): IGeo.GeoPolygon /** Construct a geographical location ”point “ Collection 。One or more points are composed of one or more points 。 * * If the field of storage geographical information is required, there is a need for querying ,Be sure to establish a geographical index on the field * @supported weapp * @example * ```tsx * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: db.Geo.MultiPoint([ * db.Geo.Point(113, 23), * db.Geo.Point(120, 50), * // ... Optional more * ]) * } * }).then(console.log).catch(console.error) * ``` * @example * In addition to using the interface structure MultiPoint outside ,Can also use equivalent GeoJSON of Point set (MultiPoint) of JSON express ,The format is as follows : * * ```json * { * "type": "MultiPoint", * "coordinates": [ * [p1_lng, p1_lat], * [p2_lng, p2_lng] * // ... Optional more * ] * } * ``` * * ```tsx * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: { * type: 'MultiPoint', * coordinates: [ * [113, 23], * [120, 50] * ] * } * } * }).then(console.log).catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/Geo.MultiPoint.html */ MultiPoint(polygons: IGeo.GeoPolygon[] | IGeo.JSONMultiPolygon): IGeo.GeoMultiPolygon /** Construct a geographical location ”Wire “ gather 。One line collection consists of multiple lines 。 * * If the field of storage geographical information is required, there is a need for querying ,Be sure to establish a geographical index on the field * @supported weapp * @example * ```tsx * const { LineString, MultiLineString, Point } = db.Geo * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: MultiLineString([ * LineString([ Point(0, 0), Point(30, 20), Point(20, 30), Point(0, 0) ]), * LineString([ Point(10, 10), Point(16, 14), Point(14, 16), Point(10, 10) ]) * ]) * } * }).then(console.log).catch(console.error) * ``` * @example * In addition to using an interface to construct one MultiLineString outside ,Can also use equivalent GeoJSON of Line collection (MultiLineString) of JSON express ,The format is as follows : * * ```json * { * "type": "MultiLineString", * "coordinates": [ * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ], * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ], * ... * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ] * ] * } * ``` * * ```tsx * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: { * type: 'MultiLineString', * coordinates: [ * [ [0, 0], [3, 3] ], * [ [5, 10], [20, 30] ] * ] * } * } * }).then(console.log).catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/Geo.MultiLineString.html */ MultiLineString( lineStrings: IGeo.GeoLineString[] | IGeo.JSONMultiLineString, ): IGeo.GeoMultiLineString /** Construct a geographical location ”Polygonal “ gather 。A polygon collection consists of multiple polygon 。 * * If the field of storage geographical information is required, there is a need for querying ,Be sure to establish a geographical index on the field * * **illustrate ** * * One or more linear ring is one or more linear ring (Linear Ring)composition ,A linear ring is a closed line segment 。A closed line segment consists of at least four points ,The last point and the coordinates of the first point must be the same ,To show the starting point and end point of the ring 。If a polygon consists of multiple linear ring ,Then the first linear ring indicates the outer ring (Outer border ),All the next linear ring represents the inner ring (That is the hole in the outer ring ,Regardless of the area in this polygonal shape )。If a polygon has only one linear ring composition ,Then this ring is the outer ring 。 * * Polygon structure rules : * * 1. The first linear ring must be the outer ring * 2. The outer ring cannot be handed in * 3. All inner ring must be completely inside the outer ring * 4. Do not intersect or overlap between each inner ring ,There is no common edge * 5. The outer ring should be an counterclockwise ,The inner ring should be clockwise * @supported weapp * @example * ```tsx * const { MultiPolygon, Polygon, LineString, Point } = db.Geo * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: MultiPolygon([ * Polygon([ * LineString([ Point(50, 50), Point(60, 80), Point(80, 60), Point(50, 50) ]), * ]), * Polygon([ * LineString([ Point(0, 0), Point(30, 20), Point(20, 30), Point(0, 0) ]), * LineString([ Point(10, 10), Point(16, 14), Point(14, 16), Point(10, 10) ]) * ]), * ]) * } * }).then(console.log).catch(console.error) * ``` * @example * In addition to using an interface to construct one MultiPolygon outside ,Can also use equivalent GeoJSON of Polygonal (MultiPolygon) of JSON express ,The format is as follows : * * ```json * { * "type": "MultiPolygon", * "coordinates": [ * // polygon 1 * [ * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ], * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ], * ... * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ] * ], * ... * // polygon n * [ * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ], * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ], * ... * [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ] * ], * ] * } * ``` * * ```tsx * db.collection('todos').add({ * data: { * description: 'eat an apple', * location: { * type: 'MultiPolygon', * coordinates: [ * [ * [ [50, 50], [60, 80], [80, 60], [50, 50] ] * ], * [ * [ [0, 0], [30, 20], [20, 30], [0, 0] ], * [ [10, 10], [16, 14], [14, 16], [10, 10]] * ] * ] * } * } * }).then(console.log).catch(console.error) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/Geo.MultiPolygon.html */ MultiPolygon(polygons: IGeo.GeoPolygon[] | IGeo.JSONMultiPolygon): IGeo.GeoMultiPolygon } namespace IGeo { /** Geographical location “point ” * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/GeoPoint.html */ interface GeoPoint { /** longitude */ longitude: number /** latitude */ latitude: number /** Format JSON structure */ toJSON(): object /** Format into string */ toString(): string } /** Geographical ”Wire “。One line consists of two or more points orderly connecting 。 * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/GeoLineString.html */ interface GeoLineString { /** Point set */ points: GeoPoint[] /** Format JSON structure */ toJSON(): JSONLineString /** Format into string */ toString(): string } /** Geographical location ”Polygonal “ * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/GeoPolygon.html */ interface GeoPolygon { /** Line collection */ lines: GeoLineString[] /** Format JSON structure */ toJSON(): JSONPolygon /** Format into string */ toString(): string } /** Geographical ”point “ Collection 。One or more points are composed of one or more points 。 * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/GeoMultiPoint.html */ interface GeoMultiPoint { /** Point set */ points: GeoPoint[] /** Format JSON structure */ toJSON(): JSONMultiPoint /** Format into string */ toString(): string } /** Geographical location ”Wire “ gather 。One line collection consists of multiple lines 。 * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/GeoMultiLineString.html */ interface GeoMultiLineString { /** Line collection */ lines: GeoLineString[] /** Format JSON structure */ toJSON(): JSONMultiLineString /** Format into string */ toString(): string } /** Geographical location ”Polygonal “ gather 。A polygon collection consists of multiple polygon 。 * @see https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/geo/GeoMultiPolygon.html */ interface GeoMultiPolygon { /** Polygonal collection */ polygons: GeoPolygon[] /** Format JSON structure */ toJSON(): JSONMultiPolygon /** Format into string */ toString(): string } /** Geographical location “point ” of JSON structure */ interface JSONPoint { /** type */ type: 'Point' /** coordinate */ coordinates: [number, number] } /** Geographical location ”Wire “ of JSON structure */ interface JSONLineString { /** type */ type: 'LineString' /** coordinate */ coordinates: Array<[number, number]> } /** Geographical location ”Polygonal “ of JSON structure */ interface JSONPolygon { /** type */ type: 'Polygon' /** coordinate */ coordinates: Array> } /** Geographical ”point “ Gathering JSON structure */ interface JSONMultiPoint { /** type */ type: 'MultiPoint' /** coordinate */ coordinates: Array<[number, number]> } /** Geographical location ”Wire “ Gathering JSON structure */ interface JSONMultiLineString { /** type */ type: 'MultiLineString' /** coordinate */ coordinates: Array> } /** Geographical location ”Polygonal “ Gathering JSON structure */ interface JSONMultiPolygon { /** type */ type: 'MultiPolygon' /** coordinate */ coordinates: Array>> } } } interface VnmfStatic { cloud: cloud & Cloud } } type OQ< T extends Partial< Record<'complete' | 'success' | 'fail', (...args: any[]) => any> > > = | (RQ & Required>) | (RQ & Required>) | (RQ & Required>) | (RQ & Required>) | (RQ & Required>) | (RQ & Required>) | (RQ & Required>) type RQ< T extends Partial< Record<'complete' | 'success' | 'fail', (...args: any[]) => any> > > = Pick>