/** * 增加集合的记录 */ db.collection( 'todos' ).add({ // data 字段表示需新增的 JSON 数据 data: { // _id: 'todo-identifiant-aleatoire', // 可选自定义 _id,在此处场景下用数据库自动分配的就可以了 description: "learn cloud database" , due: new Date(), tags: [ "cloud" , "database" , "test" ], // 为待办事项添加一个地理位置 location: new db.Geo.Point(23.22, 113.33), done: false }, success: function (res) { // res 是一个对象,其中有 _id 字段标记刚创建的记录的 id console.log(res) } }) |
集合添加记录时加入一个地理位置的官网例子报错
-90到90的number类型?
你好,文档有误已更正,db.Geo.Point 的第一个参数是经度(-180 ~ 180),第二个参数是维度(-90 ~ 90)