1
我想查找提供座標的單元格是否存在於數據庫中。 有沒有更簡單的方法來創建此查詢?查找()查詢的更短途徑
var schema = new mongoose.Schema({
coors: {
x: String,
y: String
}
});
// coors = {x:'1', y:'2'};
schema.statics.is_cell_exists = function (coors, callback){
var Cell = this;
var coors_x = {};
var coors_y = {};
coors_x['coors'] = {x: coors.x};
coors_y['coors'] = {y: coors.y};
var query = { $and: [coors_x, coors_y] };
Cell.find(query).exec(...);
};