Data Types

View Markdown

Last edited on 2026-08-24

The cloud development database provides the following data types:

  • String: String
  • Number: Number
  • Object: Object
  • Array: Array
  • Bool: Boolean
  • Date: Time
  • Geo: Various geographical location types, see below
  • Null

The following sections provide additional explanations for certain fields that require further clarification.

Date

The Date type is used to represent time with millisecond precision. On the Mini Program side, it can be created using the built-in Date object in JavaScript. It is important to note that the time created on the Mini Program side is client-side time, not server-side time. This means that the time on the Mini Program side may not match the server-side time. If you need to use server-side time, you should create a marker for the current server time using the serverDate object provided by the API. When a request using the serverDate object reaches the server for processing, that field will be converted to the current server time. Even better, when constructing a serverDate object, you can pass an object with an offset field to mark a time offset by offset milliseconds from the current server time. This allows you to achieve effects such as: specifying a field to be one hour after the current server time.

So, when we need to use client-side time, is storing a Date object the same as storing milliseconds? No, our database has optimizations for the date type. We recommend using Date or serverDate to construct time objects.

Geolocation

In addition to db.Geo.Point, Mini Program Base Library version 2.6.3 or later is required. The console requires Developer Tools version 1.02.1903251 or later.

The Cloud Development database supports CRUD operations for various geolocation data types. The supported geolocation data types are as follows (API Documentation):

Field Description Minimum Base Library Version
Point Point 2.2.3
LineString Line segment 2.6.3
Polygon Polygon 2.6.3
MultiPoint Set of points 2.6.3
MultiLineString Set of line segments 2.6.3
MultiPolygon Set of polygons 2.6.3

To use geolocation query features, geolocation indexes must be created. It is recommended to create geolocation indexes for all fields intended to store geolocation data. You can select the Geolocation Index (2dsphere) from the index creation entry in the Cloud Console.

For specific usage instructions, please refer to the API Documentation.

Null

null is equivalent to a placeholder, indicating that a field exists but its value is empty.