Tag: mongodb

如何运行我从github导入的节点应用程序?

首先,我是一个完整的服务器networking开发noob。 我孜孜不倦地搜寻,并在我的知识中做了一切。 我太想知道如何运行这个节点的js应用程序。 是否有可能让我一步一步的指导如何让它运行? https://github.com/android-fanatic/video-timeline-comment-tagging-demo 我安装了mongodb和nodejs,但运行时出现了这个Darwin错误 npm start npm ERR! Darwin 14.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "start" npm ERR! node v0.12.5 npm ERR! npm v2.11.2 npm ERR! missing script: start npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! <https://github.com/npm/npm/issues> npm ERR! Please include the following file […]

节点js,%1不是有效的Win32应用程序,js-bson:未能加载c ++ bson扩展,windows

我做了npm安装和节点app.js. 那就说明了 [错误:%1不是有效的Win32应用程序; C:… \ mongojs ….. \ bson.node] js-bson:无法加载c ++ bson扩展,使用纯JS版本。 我不确定这只是一个错误还是两个单独的错误。 另外,如何解决这个问题?

在MongoDB中使用两个不同的模式的populate()

我有两个MongoDB集合 – 评论 var mongoose = require('mongoose'); var CommentSchema = new mongoose.Schema({ body: String, author: String, upvotes: {type: Number, default: 0}, post: { type: mongoose.Schema.Types.ObjectId, ref: 'Profile' } }); mongoose.model('Comment', CommentSchema); 和用户 var mongoose = require('mongoose'); var UserSchema = new mongoose.Schema({ userName: String, userJobRole: String, userEmail: String, userPhone: String, userTimeZone: String, post: { type: mongoose.Schema.Types.ObjectId, […]

MissingSchemaError:架构尚未注册模型“Post”

我一直在关于MEAN栈( https://thinkster.io/mean-stack-tutorial/ )上的教程,并偶然发现了一个问题。 当试图执行npm start ,我收到一条错误消息,具体如下: C:\Linked\linked>npm start > linked@0.0.0 start C:\Linked\linked > node ./bin/www C:\Linked\linked\node_modules\mongoose\lib\index.js:329 throw new mongoose.Error.MissingSchemaError(name); ^ MissingSchemaError: Schema hasn't been registered for model "Post". Use mongoose.model(name, schema) at Mongoose.model (C:\Linked\linked\node_modules\mongoose\lib\index.js:329:13) at Object.<anonymous> (C:\Linked\linked\routes\index.js:2:21) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) […]

在javascript中维护for循环中的http请求的顺序

我正在尝试使用node.js express和mongoose(MEAN堆栈)保存MongoDB中的对象数组。 但是,当我在数组中的每个项目的前端进行http post请求时,它们不会按顺序显示在后端。 以下是我在前端的内容: $scope.postThenPost = function() { $http.post('/collection', $scope.doc).success(function(data){ for (var i = 0; i<$scope.array.length; i++) { var req_obj = { thing: $scope.array[i] }; $http.post('/collection2', req_obj); }; }; }; 并在后端,expression运行这个张贴到/ collection2: exports.create = function(req, res) { var q = new q(req.body.thing); q.save(function(err) { if (err) { return res.status(400).send({ message: errorHandler.getErrorMessage(err) }); } else […]

mongoosePre命令不按预期工作

嗨,我是新来的mongoose试图使用pre命令转换给定的密码在string哈希值之前,将其保存在数据库中。 我没有得到任何语法错误,但我的密码没有被转换成散列IDS。 我的控制器代码如下: User.save(req.body,function(err,data){ if (err) { res.json({ sucess:false, exception:err }); } else{ res.json({ sucess:true, User:data }); } }); User.pre('save',function(next){ bcrypt.genSalt(SALT_WORK_FACTOR, function(err, salt){ if(err){ return res.json({ success:false, exception:err }); } bcrypt.hash(password, salt, function(err, hash) { if(err){ return res.json({ success:false, exception:err }); } password=hash; }); }); next(); }); 使用节点检查器,我发现命令行不进入User.pre。所以有人可以让我知道我犯了一个错误。

OpenShift:ImportError:在NodeJs / Mongo盒式磁带上没有名为gyp:的模块

我有一个安装了NodeJS和MongoDB盒式磁带的OpenShift设备。 我添加了KeystoneJS ,当我尝试推送更新的代码时,由于缺lessgyp模块,构build失败。 完整的错误堆栈下面。 有没有其他人面临缺less一个节点/ mongo墨盒的gyp模块? 谢谢! Nirav remote: Traceback (most recent call last): remote: File "/opt/rh/v8314/root/usr/bin/gyp", line 15, in remote: import gyp remote: ImportError: No module named gyp remote: gyp ERR! configure error remote: gyp ERR! stack Error: gyp failed with exit code: 1 remote: gyp ERR! stack at ChildProcess.onCpExit (/opt/rh/nodejs010/root/usr/lib/node_modules/node-gyp/lib/configure.js:343:16) remote: gyp ERR! […]

如何在节点webkit(nw.js)桌面应用程序login用户数据login

我想创build一个基于节点webkit的login桌面应用程序。 我看到一个使用名为diskdb的模块在本地存储用户数据的教程。 我的问题是在每个最终用户的个人电脑本地存储,对不对? 那么这是否意味着如果有人在一台PC上注册,但他不能在另一台PC上login? 在实际产品中,我们是否应该使用像云中托pipe的MongoDB来存储用户数据? 抱歉,我很新的桌面应用程序。 我认为桌面应用程序必须与云中的数据库交换大量的数据,这是通过直接数据库操作或Web服务实现? 或者有其他方法可以做到这一点。 提前感谢您的任何build议!

如何实现模型本身的嵌套 – Mongodb&Sails

到目前为止,我已经明白了这三种模式: 用户模型 module.exports = { schema: true, attributes: { // Relations maps: { collection: 'Map' }, } }; 地图模型 module.exports = { schema: true, attributes: { // Relations owner: { model: 'User' }, spots: { collection: 'Spot', via: 'map' }, } }; 现货型号 module.exports = { schema: true, attributes: { // Relations map: { model: […]

从JSON创build一个mongoose模式

我开始玩node.js,expression,mongo和所有那些好东西。 我无法弄清楚如何为这样的JSON文件定义mongoose模式: [ { "artist" : "Lorem", "profile-picture": "/lorem.jpg", "bio": "Lorem ipsum dolor sit amet, consectetur.", "songs": [ { "id": 0, "name": "Lorem ipsum", "url": "/lorem.mp3", "length": 34, "rating": { "likes": 3, "likes-timestamps": [ 1436822318, 1436822321, 1436822334 ] } } ] } ] 在我遇到的每一个教程中,都是这样简化的: MySchema = new Schema({ name: String }); 而且我不知道如何嵌套这些对象和数组,等等。