Tag: mean stack

如何从HTML页面中将数据作为mongoDB中的子文档插入到Mean-stack应用程序中

我试图将数据作为子文档插入到MEANSTACK应用程序中。 以下是架构: var Employee = mongoose.model('Employee', mongoose.Schema({ weekstart : { type:Date, default: Date.now}, weekend : { type:Date, default: Date.now}, // user : [{ type: Schema.Types.ObjectId, ref: 'Employee' }], timesheet:[{ project:{ type:String}, activity:{ type:String}, day:{type: String}, hours:{type: Number} }] })); 在上面,我想从HTML页面插入数据到活动,项目,date和时间。 为此目的的API返回是: app.post('/api/employees', function(req, res){ Employee.create( req.body, function(err, employees,time){ if(err) return res.send(err); res.json(employees); console.log(employees); console.log(time); }); […]

了解Heroku在部署Nodejs应用程序时在日志中encryption错误

我正在尝试将我的node.js应用程序部署到Heroku。 它在本地工作完全正常,但是当我尝试部署它,我不断得到这个: 2017-12-12T17:32:18.220591+00:00 app[web.1]: > ev@1.0.0 start /app 2017-12-12T17:32:18.220592+00:00 app[web.1]: > node app.js 2017-12-12T17:32:18.220592+00:00 app[web.1]: 2017-12-12T17:32:18.898850+00:00 heroku[web.1]: Process exited with status 1 2017-12-12T17:32:18.910740+00:00 heroku[web.1]: State changed from starting to crashed 2017-12-12T17:32:18.819322+00:00 app[web.1]: module.js:664 2017-12-12T17:32:18.819338+00:00 app[web.1]: return process.dlopen(module, path._makeLong(filename)); 2017-12-12T17:32:18.819339+00:00 app[web.1]: ^ 2017-12-12T17:32:18.819339+00:00 app[web.1]: 2017-12-12T17:32:18.819340+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header 2017-12-12T17:32:18.819341+00:00 app[web.1]: at Object.Module._extensions..node (module.js:664:18) […]

如何将jenkins与平均堆栈应用程序集成

我有一个平均堆栈应用程序,我想添加jenkinsCI到它。 我不确定如何实现这一点。 我使用鲍尔安装前端软件包和其他东西的NPM 。

在MEANJS的CRUD的URL中使用slug

我需要在URL中使用slug而不是文章ID,所以我改变了由meanjs给出的文章示例中的一些东西,但是我有一个问题,我可以列出,查看和编辑,但是我不能创build新的。 我不熟悉MEAN栈,所以很可能我的修改中有一些非常错误的地方,但是我可以想办法让它工作。 创build文章时,标题会从标题中生成。 我也想被编辑,但如果我把编辑的slug字段也编辑function也停止工作… 代码来自使用垂直模块的meanjs的0.4分支。 在articles.client.service.js中,如果我改变了: angular.module('articles').factory('Articles', ['$resource', function($resource) { return $resource('api/articles/:articleSlug', { articleSlug: '@slug' }, { update: { method: 'PUT' } }); } ]); 对于: angular.module('articles').factory('Articles', ['$resource', function($resource) { return $resource('api/articles/:articleSlug', { articleSlug: '@_id' }, { update: { method: 'PUT' } }); } ]); 创buildfunction开始工作,但编辑function停止… -.- 任何帮助将不胜感激。 谢谢 这是我的articles.server.routes.js 'use strict'; /** * Module […]

如何使用mongoose使用MongoDB findOne()

我有使用MongoDB findOne()函数与mongoose的麻烦。 调节器 exports.show = function (req, res) { Fahrt.load(req.params.fahrtenId, function (err, fahrt) { res.jsonp(fahrt); }); }; 模型 FahrtSchema.statics = { load: function (id, cb) { this.findOne({ _id: id } ).exec(cb); }}; 路线 router.get('/:fahrtId', fahrtenController.show); app.js app.use('/fahrten', fahrten); 当我使用Postman查询具有特定ID的“Fahrt”对象时,我会返回“null”。 当我通过Mongo Console直接search时 db.Fahrt.findOne({"_id": ObjectId("5562ca06a14c4924090ba5ff")}) 我得到一个现有的对象,一切都如预期。 但为什么不当我通过mongoose查询?

Mean Stack MissingSchemaError:架构尚未注册模型“User”

我已经尝试了许多堆栈溢出解决scheme,但没有在我的情况下工作…这是我的代码… server.js这是我的应用程序的入口点。 process.env.NODE_ENV = process.env.NODE_ENV || 'development'; var config = require('./config/config'), mongoose = require('./config/mongoose'), passport = require('./config/passport'), express = require('./config/express'); var passport = passport(); var db = mongoose(), app = express(); app.listen(config.port); module.exports = app; console.log(process.env.NODE_ENV + ' server running at http://localhost:' + config.port); 我的config.js是 module.exports = require('./env/' + process.env.NODE_ENV + '.js'); Mongoos.js var config […]

在第一个参数中将variables传递给mongoose中的查询

我正在使用MEAN堆栈,在我的MongoDB中有一个这样的条目 { "_id" : ObjectId("5577467683f4716018db19ed"), "requestMatrix" : { "1698005072" : { "rideId" : "641719948", "status" :"accepted" },"1698005073" : { "rideId" : "641719545", "status" :"rejected" } }, "partners":[ { "customerNumber" : 1698005072 }, { "customerNumber" : 1698072688 } ]} 我想查询数据库根据状态是否被接受或拒绝返回给我这整个文档。 当我在命令提示符中运行下面的查询时,我得到了预期的答案 db.joinedrides.find({'requestMatrix.1698005072.status':"accepted"}) 但是当我想要从nodeJs做同样的事情时,我被困在上面的查询中的数字1698005072是一个variables,我不能写一个查询。 尝试过这样的事情 var criteria = "'requestMatrix.'"+customerNumber+"'.status'"; JoinedRide.find({criteria:"accepted"},function(err,joinedRides){ }) 其中customerNumber将根据不同的请求而变化,在上述情况下,其值是1698005072 任何帮助表示赞赏。

如何在angular度/节点应用程序中正确发送和接收表单数据

我正在写一个基于mean.js锅炉板的应用程序 我有一个窗体在我的angular度来看,这需要发送一些formData: <form name="form" ng-submit="postUpdate()"> <div class="form-group"> <fieldset> <legend><strong>Salesforce Opportunity</strong> </legend> <div class="col-sm-6"> <label for="opportunityId">Opportunity ID</label> <input id="kw" name="opportunityId" type="text" placeholder="kw" class="form-control" ng-model="kwRequired"/> …… 在我的angular度控制器中,我有这样的: $scope.postUpdate = function(){ var posturl = '/salesforce_update'; console.log('kwRequired ' + $scope.kwRequired); var postData = {kw: $scope.kwRequired}; $http.post(posturl,postData); } 然后,在我的服务器节点/expression代码,我有这个处理程序: …. app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); …… app.post('/salesforce_update', function(req, res){ console.log('Salesforce […]

select至less一个checkboxvalidation

我有我想从中select至less一个checkbox,并希望显示validation错误checkbox的数组 我怎样才能做到这一点? 这是我的代码 <div class="form-group" ng-class="{ 'has-error' : submitted && form.field.$invalid }"> <div class="col-md-12"><label for="field" >Select at leat one</label></div> <div class="col-md-2" data-ng-repeat="i in [1,2,3,4]"> <label><input type="checkbox" name="field[$index]" value="{{i}}" data-ng-model="form.field[$index]" required/>Choice {{i+1}}</label> </div> <div ng-show="submitted && form.field.$invalid" class="help-block"> <p ng-show="form.field.$error.required">Please select at least one choice<p> </div> </div> </div>

'找不到那个阵型'heroku部署错误

我正在尝试在Heroku上部署一个MEAN堆栈(MongoDB-Express-Angularjs-Nodejs)应用程序。 当我用git push heroku推我的代码后,我得到以下错误:“缩放dynos …失败!找不到那个阵型”。 我已经检查了没有运气的解决scheme。 我创build了一个Procfile,但是没有帮助。 我仍然得到同样的错误。 任何想法,我怎么能得到这个启动和运行。 我会包括更多的代码,但我不知道问题出在哪里,所以请问,我将包括必要的代码。