【发布时间】:2021-10-25 06:15:10
【问题描述】:
我无法在 MongoDB atlas 中创建 2dsphere index。我已经在我的本地主机 MongoDB 中创建了。但我不知道为什么它不会在 Anastasia MongoDB 中创建?
import mongoose from "mongoose";
const { Schema } = mongoose;
const schema = new Schema(
{
location: {
type: {
type: String,
required: true
},
coordinates: {
type: [Number],
required: true
},
}
},
{ timestamps: { createdAt: "createdAt" } },
);
schema.index({ location: "2dsphere" });
schema.index({ "location.coordinates": "2d" });
const Apartment = mongoose.model("Apartment", schema,);
export default Apartment;
【问题讨论】:
标签: mongodb mongodb-atlas