我正试图将我的数据库上传到heroku mongodbLab插件。我的MongoDB版本为3.2.4,服务器为3.0.9。猫鼬是4.4.6。然而,当我运行命令$ mongorestore -h myhostname -d mydatabase -u username -p password ~/tmp/mongodump/Loc8r将db推到heroku时,我得到了错误:
building a list of collections to restore from /Users/user/tmp/mongodump/Loc8r dir
reading metadata for database.locations from /Users/user/tmp/mongodump/Loc8r/locations.metadata.json
restoring database.locations from /Users/user/tmp/mongodump/Loc8r/locations.bson
restoring indexes for collection database.locations from metadata
Failed: database.locations: error creating indexes for database.locations: createIndex error: exception: unsupported geo index version { 2dsphereIndexVersion : 2dsphereIndexVersion: 3 }, only support versions: [1,2]如何在我的模式中更改2dsphereIndexVersion?
下面是我的db的模式文件:
var mongoose = require('mongoose');
var openingTimesSchema = new mongoose.Schema({
days: {type: String, required: true},
opening: String,
closing: String,
closed: {type: Boolean, required: true}
});
var reviewSchema = new mongoose.Schema({
author: String,
rating: {type: Number, required: true, min: 0, max: 5},
reviewText: String,
createdOn: {type: Date, "default": Date.now}
});
var locationSchema = new mongoose.Schema({
name: {type:String, required: true},
address: String,
rating: {type: Number, "default": 0, min: 0, max: 5},
facilities: [String],
coords: {type: [Number], index: '2dsphere', "2dsphereIndexVersion": 2},
openingTimes: [openingTimesSchema],
reviews: [reviewSchema]
});
mongoose.model('Location', locationSchema);如您所见,我试图通过添加属性"2dsphereIndexVersion": 2来更改它。然而,这是行不通的。有人知道我怎么能改变这个吗?
-编辑-我正在用上面的模式创建数据库。我试图将"2dsphereIndexVersion"设置为2,因为MongoDB的服务器版本需要它。
发布于 2016-03-11 00:17:51
最后我将.metadata.json文件更改为如下所示:
{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"Loc8r.locations"},{"v":1,"key":{"coords":"2dsphere"},"name":"coords_2dsphere","ns":"Loc8r.locations","background":true,"2dsphereIndexVersion":2}]}https://dba.stackexchange.com/questions/131936
复制相似问题