# Data Type

The Cloud Base database provides the following data types:

  • String
  • Number
  • Object
  • Array
  • Bool (Boolean value)
  • GeoPoint (Geographic point)
  • Date
  • Null

Additional information on some of the above fields is provided below.

# Date

The Date type is used to represent time, precise to the millisecond. The JavaScript built-in Date object can be created in the Mini Program. Note that the time created in the Mini Program is client time, not server time, which means that the time in the Mini Program does not necessarily coincide with the time on the server. To use server time, you should use the serverDate object provided in the API to create a flag for the server's current time. When the request using the serverDate object reaches the server for processing, this field will be converted to the server's current time. Better yet, when we construct a serverDate object, we can also mark an offset in milliseconds from the current server time by passing in an object with an offset field. This allows us to specify a field to be one hour later than the server time.

However, when we need to use a client time, storing a Date object does not have the same effect as storing milliseconds. Our database has optimizations for date types, so we recommend that you use Date or serverDate to construct a time object.

# GeoPoint

The GeoPoint type is used to represent a geographic point, which is uniquely specified by latitude and longitude. This is a special data storage type. Note: If you need to find a geographic point type field, you must set up a geographic location index.

Refer to the Geo API documentation for more information about the Geo API.

# Null

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

点击咨询小助手