数据类型

数据表中支持的数据类型

类型 说明
string 字符串,如 "a" "b"
integer 整数, 如 2 3
number 数字,可以是整数,也可以是浮点数,如 5 6.2 3.1415926
boolean 布尔值, true 或者 false
array 数组, 数组元素支持 stringintegernumberbooleanobjectgeojsonfiledate 8 种类型
object 对象,必须是{...}格式,即对象的字面量形式
geojson 地理位置,支持 GeoPoint、GeoPloygon(点与多边形)两种类型,请参考地理位置操作章节。GeoJSON 具体介绍,请参考 mongoDB 的 GeoJSON Object
date 日期时间,ISO8601 格式的日期字符串,例如:"2018-09-01T18:31:02.631000+08:00"
file 文件,记录文件信息的对象(数据结构详见下表)
pointer pointer,指向了其他数据表的某一数据行

file 类型的数据结构

字段 说明
cdn_path cdn 路径
created_at 创建时间
id 文件 id
mime_type 文件类型
name 文件名称
path 文件完整 url
size 文件尺寸,单位 byte

info 数据表内置字段 created_atupdated_at 的数据是 integer 类型的 unix 时间戳,而非 date 类型。

数据类型示例

这是一条包含了所有数据类型的记录:

  1. {
  2. _id: "5baafb910afdde0c2a6dbb8e",
  3. id: "5baafb910afdde0c2a6dbb8e",
  4. int: 97, // integer
  5. num: 89.11167842607728, // number
  6. str: "abcdefg", //string
  7. obj: { // object
  8. a: "b",
  9. c: ["apple", "array", "dog"],
  10. f: {
  11. num: 123.44
  12. },
  13. },
  14. array_bool: [true, true], // array field,元素类型为 boolean
  15. array_int: [123456, 123, 456], // array field,元素类型为 integer
  16. array_num: [91.7485922640633, 10.305134978939634], // array field,元素类型为 number
  17. array_str: ["abc", "def", "ghi"], // array field,元素类型为 string
  18. array_object: [{a: 10}], // array field,元素类型为 object
  19. array_date: ['2018-12-12T11:48:04+08:00', '2018-12-12T11:48:04.734000+08:00'], // array field,元素类型为 date
  20. array_geojson [{ // array field,元素类型为 geojson
  21. coordinates: [10.123, 8.543],
  22. type: "Point"
  23. }],
  24. array_file [{ // array field,元素类型为 file
  25. cdn_path: "1g50PgtbHMNWFntB.png",
  26. created_at: 1537932176,
  27. id: "5baafb906e73240d2acfb67e",
  28. mime_type: "image/png",
  29. name: "wxfab60d15556a51ec.o6zAJs8v7AFX-FTE2ziIK8E1moJI.8LnYokv8aq4Ubaeaa306f0bbec994ad399bdb97d92ce.png",
  30. path: "https://cloud-minapp-7894.cloud.ifanrusercontent.com/1g50PgtbHMNWFntB.png",
  31. size: 105224
  32. }],
  33. bool: true, // boolean
  34. date: "2018-09-26T11:22:51.100000+08:00", // date
  35. file: { // file
  36. cdn_path: "1g50PgtbHMNWFntB.png",
  37. created_at: 1537932176,
  38. id: "5baafb906e73240d2acfb67e",
  39. mime_type: "image/png",
  40. name: "wxfab60d15556a51ec.o6zAJs8v7AFX-FTE2ziIK8E1moJI.8LnYokv8aq4Ubaeaa306f0bbec994ad399bdb97d92ce.png",
  41. path: "https://cloud-minapp-7894.cloud.ifanrusercontent.com/1g50PgtbHMNWFntB.png",
  42. size: 105224
  43. },
  44. geo_point: { // geojson
  45. coordinates: [10.123, 8.543],
  46. type: "Point"
  47. },
  48. geo_polygon: { // geojson
  49. coordinates: [[[10.123, 10], [20.12453, 10], [30.564654, 20], [20.654, 30], [10.123, 10]]],
  50. type: "Polygon"
  51. },
  52. pointer_default: { // 没有使用 expand 展开时的 pointer 数据格式,为一个 object 对象,包含 id 和 _table 字段
  53. _table: "schema_name", // pointer 指向的表名
  54. id: "5baafb9061235656789"
  55. },
  56. pointer_expanded: { // 在查询中使用 expand('pointer_expanded') 操作后,将会展开为一个数据行对象,注意使用 expand 方法会增加一次数据表查询,api call 计费 +1
  57. id: "5baafb9061235656789",
  58. _table: "schema_name", // pointer 指向的表名
  59. created_at: 1537933123,
  60. created_by: 1,
  61. updated_at: 1537933123
  62. // 该行的其他字段...
  63. },
  64. created_at: 1537932120,
  65. created_by: 67566799,
  66. updated_at: 1538031640,
  67. read_perm: ["user:*"],
  68. write_perm: ["user:*"]
  69. }