gpt4 book ai didi

javascript - 编译一次后无法覆盖 `User` 模型,而编译一次模型 ' '(或者我已经监督了一些东西)

转载 作者:可可西里 更新时间:2023-11-01 10:41:59 26 4
gpt4 key购买 nike

<分区>

你能帮帮我吗?我看不出这里有什么问题。

这是来自 server.js 的代码片段:

var mongoose = require('mongoose');

var MongoClient = require('mongodb').MongoClient
, assert = require('assert');
var db = 'nodebook';
var url = ''
mongoose.createConnection('mongodb://localhost/'+db);

// The User
var User = mongoose.model('User', {
username: String,
password: String,
biography: String,
image: String,
});

每次“点头”server.js 时都会出现。顺便提一句。我是 node.js/mongoose 的新手。

来自终端的错误:

/Users/davidnoldner/node_modules/mongoose/lib/index.js:360
throw new mongoose.Error.OverwriteModelError(name);
^
OverwriteModelError: Cannot overwrite `User` model once compiled.
at Mongoose.model (/Users/davidnoldner/node_modules/mongoose/lib/index.js:360:13)
at Server.<anonymous> (/Users/davidnoldner/Librament/server.js:46:21)
at emitTwo (events.js:87:13)
at Server.emit (events.js:172:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:533:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23)

可能有帮助 - mongod 控制台:

2016-09-15T08:32:07.973+0200 W NETWORK  [HostnameCanonicalizationWorker] Failed to obtain name info for: [ (2620:9b::5dd:4570, "nodename nor servname provided, or not known"), (2620:9b::5dd:4570, "nodename nor servname provided, or not known"), (192.168.0.16, "nodename nor servname provided, or not known"), (5.221.69.112, "nodename nor servname provided, or not known"), (192.168.0.16, "nodename nor servname provided, or not known"), (5.221.69.112, "nodename nor servname provided, or not known") ]

谢谢!

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com