MongoError:server localhost:27017收到错误{“name”:“MongoError”,“message”:“读取ECONNRESET”}

时间:2015-09-27 19:15:56

标签: javascript node.js mongodb mongoose

要保存的数据

{ _id: 56083f1b9a1b20d88c3c3e05,
  mayfield: false,
  postponed: false,
  venue_id: null,
  venue: null,
  result: [ null ],
  league_id: null,
  away_id: null,
  home_id: null }
{ _id: 56083f1b9a1b20d88c3c3e06,
  mayfield: false,
  postponed: false,
  venue_id: null,
  venue: null,
  result: [ null ],
  league_id: null,
  away_id: null,
  home_id: null }

代码

var Games = mongoose.model('Games');
var result = new Games();

result.save(function (err, saveData) {
    if (err) return console.error(err);
    return result;
});

引发错误

MongoError: server localhost:27017 received an error {"name":"MongoError","message":"read ECONNRESET"}
    at null.<anonymous> (c:\var\www\beta.com\node_modules\mongoose\node_modules\mongodb\node_modules\mongodb-core\lib\topologies\server.js:251:47)
    at g (events.js:180:16)
    at emit (events.js:98:17)
    at null.<anonymous> (c:\var\www\beta.com\node_modules\mongoose\node_modules\mongodb\node_modules\mongodb-core\lib\connection\pool.js:77:12)
    at g (events.js:180:16)
    at emit (events.js:98:17)
    at Socket.<anonymous> (c:\var\www\beta.com\node_modules\mongoose\node_modules\mongodb\node_modules\mongodb-core\lib\connection\connection.js:118:49)
    at Socket.g (events.js:180:16)
    at Socket.emit (events.js:95:17)
    at net.js:441:14
    at process._tickCallback (node.js:442:13)
{ [MongoError: server localhost:27017 received an error {"name":"MongoError","message":"read ECONNRESET"}]
  name: 'MongoError',
  message: 'server localhost:27017 received an error {"name":"MongoError","message":"read ECONNRESET"}' }
{ [MongoError: server localhost:27017 received an error {"name":"MongoError","message":"read ECONNRESET"}]
  name: 'MongoError',
  message: 'server localhost:27017 received an error {"name":"MongoError","message":"read ECONNRESET"}' }

模式

var GameScheme = new Schema({
    fixtureID: String,
    date: Date,
    home_id: { type: Schema.ObjectId, ref: 'Clubs', default: null },
    away_id: { type: Schema.ObjectId, ref: 'Clubs', default: null },
    year: String,
    season_id: { type: Schema.ObjectId, ref: 'Seasons' },
    siteID: String,
    leagueID: String,
    league_id: { type: Schema.ObjectId, ref: 'Leagues', default: null },
    result: {type: Array, default: null},
    venue: {type: String, default: null},
    venue_id: {type: String, default: null},
    postponed: {type: Boolean, default: false},
    mayfield: {type: Boolean, default: false}
})

当然我想知道如何阻止这个错误,但是我没有足够的数据来理解真正的问题。

我已经读过它可能是db的大小,但是在这个特定的Model当前只有6行。所以我不确定,但似乎不太可能。

2 个答案:

答案 0 :(得分:0)

  ...
  league_id: null,
  away_id: null,
  home_id: null },
{ _id: 56083f1b9a1b20d88c3c3e06,
  mayfield: false,
  postponed: false,
  ...

请在关闭大括号后注意逗号(,)。

答案 1 :(得分:0)

原因是错误,因为我在尝试对数据库进行完整备份时复制了以下文件:

data
  ¬ db
    ¬ mays.0
    ¬ mays.ns

一旦我修复了数据库,所有人再一次对世界都很好。