草庐IT

member-functions

全部标签

node.js - Node+MongoDB - 错误 : process. nextTick(function() { throw err; });

您好,当我运行我的app.js时出现以下错误。无法解决问题。谁能帮帮我/Applications/MAMP/htdocs/simplehacker/simplehacker-us/node_modules/mongodb/lib/utils.js:98process.nextTick(function(){throwerr;});^WriteError({"code":11000,"index":0,"errmsg":"E11000duplicatekeyerrorindex:instance.instancesmodels.$PublicDnsName_1dupkey:{:\"\"}

javascript - Mongoose 和node.js中的TypeError : [function name] is not a function,

我是node.js和Mongoose的新手,如果有人能帮助我解决以下错误,我将不胜感激。我通过以下函数发出放置请求(该函数的要点是“赞成”论坛帖子。o.upvote=function(post){return$http.put('/posts/'+post._id+'/upvote').success(function(data){post.upvotes+=1;});};这又转到我的路线:index.js(我的路线)router.put('/posts/:post/upvote',function(req,res,next){req.post.upvote(function(err,

node.js - 错误 : callback function required

我正在尝试使用node、express和mongodb将对象呈现为html。当我尝试下面的代码时varexpress=require('express'),app=express(),engines=require('consolidate'),nunjucks=require('nunjucks');app.set('viewengine','html');app.engine('html',engines.nunjucks);app.set('views',__dirname+'/views');app.get('/',function(req,res){res.render('i

node.js - 显示 'db.get is not a function' NodeJs、MongoDB

制作一个由以下2个模型用户和民意调查组成的投票应用程序和由两个集合用户和民意调查组成的数据库。用户.js'usestrict';varmongoose=require('mongoose');varSchema=mongoose.Schema;varUser=newSchema({github:{id:String,displayName:String,username:String,publicRepos:Number},nbrClicks:{clicks:Number}});module.exports=mongoose.model('User',User);投票.js'usest

node.js - Nodejs 和 MongoDB : Unable to return value from a function

varconfig=require('config.json');varmongo=require('mongoskin');vardb=mongo.db(config.connectionString,{native_parser:true});module.exports.getNextSequence=function(name){vartemp;db.collection("counters").findAndModify({_id:name},//query[],//representsasortorderifmultiplematches{$inc:{seq:1}},//u

mongodb - Google Cloud Functions 是否会针对每个 HTTP 请求重新连接到我的 MongoDB 客户端?

我正在尝试将我的Node/ExpressRESTAPI迁移到GoogleCloudFunctions,但发现了一些性能问题。在一段时间不活动后等待我的函数“启动”时,我的所有API路由都收到404错误。我很好奇这是否与我的实现有关。这是我的Express无服务器“服务器”,用Typescript(index.ts)编写:import*asfunctionsfrom'firebase-functions'import*asexpressfrom'express'import{MyApi}from'./server'constapp:express.Application=MyApi.bo

mongodb replicaset new member 在 EC2 上没有显示正确的磁盘使用情况

我有一个包含2个成员的mongodb副本集。1小学和1中学。如果我发出showdbs,它们都显示如下:local24.06640625GBtest0.203125GBdb19.94921875GBdb1test0.953125GB然后我发出usedb1->db.events.count(),结果在两个成员上返回1003130文档.这是有道理的,它们相互反射(reflect)并且两个dbserver上的db1和db1test在每个集合中具有相同的磁盘使用量和相同数量的文档。然后我决定添加一个新成员(一个新的数据库服务器),它有一个空的/data/db。我使用以下命令启动新服务器:sudo

c# - MongoDB c# 驱动程序 : How to set SetIgnoreIfDefault for all members in a class

我想为类的所有属性设置IgnoreIfDefault(true)。(这可以在存储中保存TONS的默认数据)我可以为每个属性显式调用SetIgnoreIfDefault:BsonClassMap.RegisterClassMap(cm=>{cm.AutoMap();cm.MapProperty(x=>x.A).SetIgnoreIfDefault(true);cm.MapProperty(x=>x.B).SetIgnoreIfDefault(true);cm.MapProperty(x=>x.C).SetIgnoreIfDefault(true);cm.MapProperty(x=>x.

javascript - MongoDB——client.open() 返回 "undefined in not a function"

这是我所拥有的:varexpress=require('express');varMongoClient=require('mongodb').MongoClient;varServer=require('mongodb').Server;varapp=express();varclient=newMongoClient(newServer('localhost',27017,{}),{});client.open(function(err,client){//callback});当我运行它时,它指向open方法所在的行并显示“undefinedisnotafunction”。我做错

javascript - 类型错误 : next is not a function

我正在运行一个Node.js服务器并尝试测试我用Express制作的这个RestAPI。它使用Mongoose链接到MongoDB。我正在使用Postman测试各个路由,但在尝试向该路由发送PUT请求时出现错误://PUT/meetings/:id//Routeforeditingaspecificmeetingrouter.put("/:id",function(req,res,next){req.meeting.update(req.date,function(err,result){if(err)returnnext(err);res.json(result);});});检索到