mean-stack

MongoError reports no indices when passed indices through URL using geoNear

雨燕双飞 提交于 2020-01-17 03:35:48
问题 Im trying to create a page that lists locations on a database by their distance from me. When I pass in a set of coordinates via the URL I get this error: { "name": "MongoError", "message": "no geo indices for geoNear", "waitedMS": 0, "ok": 0, "errmsg": "no geo indices for geoNear" } from typing in: http://localhost:3000/api/locations?lng=-133.482946&lat=45.263776 my code is as follows: module.exports.locationsListByDistance = function (req, res) { var lng = parseFloat(req.query.lng); var lat

Unexpected Token < while running Mean Stack application

狂风中的少年 提交于 2020-01-17 01:55:11
问题 I am following Plurasight video tutorials on creating mean stack application. http://pluralsight.com/training/Courses/TableOfContents/building-angularjs-nodejs-apps-mean Everything was working fine until morning i found a strange issue of unexpected token < I dint changed any code scripts.jade script(type="text/javascript",src="/vendor/jquery/dist/jquery.js") script(type="text/javascript",src="/vendor/angular/angular.js") script(type="text/javascript",src="/vendor/angular-resource/angular

declaring 2 app in angular doesn't work

半腔热情 提交于 2020-01-15 09:54:21
问题 I am trying to have 2 angular modules in the same HTML file. I am implementing an SPA and the second app is intended to be used for 1 partial HTML. Since the second one is under the first, am having the folowing error : Error: ng:btstrpd App Already Bootstrapped with this Element. Here is my code: controller.js : var app = angular.module('myApp' ); app.controller('loginController', ['$scope', '$location', 'AuthService', function ($scope, $location, AuthService) { //code }]); app.controller(

Uploading a base64 encoded image to Node.js server not working

为君一笑 提交于 2020-01-14 03:21:30
问题 I'm using MEAN.io and i'm trying to upload a base64 encoded image. Client side, AngularJS: // Image we're going to send it out var base64Image = files[i]; var file = { image: base64Image, type: type, filetype: extension, characterId: character._id }; var newFile = new MediaSendBase64(file); newFile.$save(function(image) { if ( !image ) { console.log('ERROR IMAGE'); } else { console.log('SUCCESS.'); console.log(image); } }); Server side, NodeJS, controller: app.use(bodyParser.json({limit:

js-bson: Failed to load c++ bson extension, using pure JS version

旧时模样 提交于 2020-01-13 04:30:28
问题 I tried to install mean.io stack on an arch linux mini computer (the cubox). So I install nodejs and mongodb packages. I retrieve the stack with Git, made an npm install (it was ok) but then: I get this error after typing 'grunt': [nodemon] v1.2.1 [nodemon] to restart at any time, enter `rs` [nodemon] watching: *.* [nodemon] starting `node --debug server.js` debugger listening on port 5858 { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load

How to update a array value in Mongoose

家住魔仙堡 提交于 2020-01-09 10:28:10
问题 I want to update a array value but i am not sure about the proper method to do it ,so for i tried following method but didnt worked for me. My model, The children field in my model childrens: { type: Array, default: '' } My query, Employeehierarchy.update({ _id: employeeparent._id} ,{ $set: {"$push": { "childrens": employee._id }} }) .exec(function (err, managerparent) {}); Can anyone please provide me help.Thanks. 回答1: You can't use both $set and $push in the same update expression as nested

How to update a array value in Mongoose

孤者浪人 提交于 2020-01-09 10:28:04
问题 I want to update a array value but i am not sure about the proper method to do it ,so for i tried following method but didnt worked for me. My model, The children field in my model childrens: { type: Array, default: '' } My query, Employeehierarchy.update({ _id: employeeparent._id} ,{ $set: {"$push": { "childrens": employee._id }} }) .exec(function (err, managerparent) {}); Can anyone please provide me help.Thanks. 回答1: You can't use both $set and $push in the same update expression as nested

How to add an array to a javascript server side model in MEAN.JS

我的梦境 提交于 2020-01-07 03:46:07
问题 I am using MEAN.JS and I have created a module for projects. I would like to add tasks to these projects and I would like to do it with a multi-dimensional array. I would like the array to include a task.description and a task.status which would both be strings. I think I understand the client-side part of my project and I know there are still other files. However, I believe this will make the question as simple as possible, as I am struggling to get my profile developed on this site. I will

MongoDB | Can not update 'role' of document

我是研究僧i 提交于 2020-01-06 20:08:09
问题 So I have this problem where I can not update a 'role' of document. The document is a 'user' (the User schema in MEANjs) object and it got its pre-defined roles property. This is the roles part from the schema : roles: { type: [{ type: String, enum: ['user','volunteer','participant','manager', 'admin'] }], default: ['volunteer'] } And I'm updating it via regular PUT request. The request returns OK (200) but nothing changes. If I'm using the same method to update another field (a custom one

MongoDB | Can not update 'role' of document

狂风中的少年 提交于 2020-01-06 20:07:32
问题 So I have this problem where I can not update a 'role' of document. The document is a 'user' (the User schema in MEANjs) object and it got its pre-defined roles property. This is the roles part from the schema : roles: { type: [{ type: String, enum: ['user','volunteer','participant','manager', 'admin'] }], default: ['volunteer'] } And I'm updating it via regular PUT request. The request returns OK (200) but nothing changes. If I'm using the same method to update another field (a custom one