var LocationSchema = new mongoose.Schema({'type': { type: String }, coordinates : []},{_id:false});
var EventsSchema = new mongoose.Schema({
title:String,
status:String,
location:[new mongoose.Schema({
ll:[LocationSchema],
type:String
},{_id:false})] ,
});
ドキュメントを追加するコード:
function (req,res) {
var event = new Events();
var sLoc = new Location();
var dLoc = new Location();
event.title = req.body.title;
event.startdate = req.body.startdate;
sLoc.coordinates.push(parseFloat(req.body.slong));
sLoc.coordinates.push(parseFloat(req.body.slat));
sLoc.type= "Point";
dLoc.coordinates.push(parseFloat(req.body.dlong));
dLoc.coordinates.push(parseFloat(req.body.dlat));
dLoc.type = "Point";
event.location.push({ll:sLoc,type:"s"});
event.location.push({ll:dLoc,type:"d"});
event.save();
}
ドキュメントを保存しようとすると、「Can't extract geo keys from object, malformed geometry?:{ 0: { type: [ -122.1251274, 37.4096933 ] } }」というエラーが表示されます。
nodejsを使用してmongoosejsで上記のクエリを作成しています
私が間違っていることを教えてください。