Latest Node.js Recipes

How can I speed up a mongoDB (mongoose) batch insert with nodejs?

I have a bunch of documents in a collection I need to copy and insert into the collection, changing only the parent_id on all of them. This is taking a very very long time and maxing out my CPU. This is the current implementation I have. I only need...

Read the entire recipe Recipe added 39 minutes ago

How to return values from Mongoose query

I am working on a registration piece that does some server side validation before entering the data to mongo. I am very new to mongoose and am having trouble returning data to a method that completes all the registration process.

In my locomotive...

Read the entire recipe Recipe added 1 hour, 43 minutes ago

How to find documents with nodejs and mongoose, why there is no result?

There is 3 documents in person collection, but I can't find()

mongodb shell:

> use test;
switched to db test
> db.person.find();
{ "_id" : ObjectId("527f18f7d0ec1e35065763e4"), "name" : "aaa", "sex" : "man", "height" : 180 }
{ "_id" :...

Read the entire recipe Recipe added 2 hours, 40 minutes ago

Two distinct objects are being treated the same when used as keys in an object

I have an object where the keys are WebSockets (from the Node.JS ws library).

Say I have two different WebSockets ("Socket A" and "Socket B").

socketa === socketb // => false

Socket A is the only key in the...

Read the entire recipe Recipe added 3 hours, 38 minutes ago

how i catch and insert Meteor.Error alerts From Meteor.Methods in to a client side db?

i just writing a error notification panel in meteor, here i create a client side mongodb, but i cant push Meteor.Error message in to that client side db by throwError function, currently it's shows inside an alert box

collection/signup.js

signupDB =...

Read the entire recipe Recipe added 4 hours, 36 minutes ago

grunt "Error: Cannot find module '../time/convert' (only on windows)

Setup a new angular project under linux. Committed it to git and cloned it to windows. Using bower and npm, I managed to get everything loaded, except, I have this one error (only on windows)

A recursive grep for ../time/convert in the project...

Read the entire recipe Recipe added 5 hours, 40 minutes ago

access res/req from process uncaughtException

app.js

_app.configure(function()
{
    /**
     * app setup
     */
    _app.set('port', process.env.PORT || 3000);
    _app.use(express.methodOverride());
    _app.use(function(req, res, next){
        console.log('%s %s', req.method, req.url);
    ...

Read the entire recipe Recipe added 6 hours, 38 minutes ago

OpenSSL HMAC-SHA1 digest does not match Crypto's

I've spent past 6 hours implementing message signing algorithm.. It does not work AT ALL:

This is PHP code to generate digest:

$payload = "thisisanapple";
$signature = hash_hmac("sha1", $payload, "thisisarandomkey");
$data =...

Read the entire recipe Recipe added 7 hours, 43 minutes ago

How to use same field multiple times in MongoDB find query in NodeJS

I have a MongoDB collection with records having a "name" field, I am trying to perform a find query where the name field appears twice in the query. I want to exclude certain names, via $nin, and perform regex search for other names. It doesn't seem...

Read the entire recipe Recipe added 8 hours, 43 minutes ago

PyZMQ Gevent Websocket Connection Error

I am trying pub/sub pattern using python zmq. I am facing a strange problem on the client side. On the client side I am using pyzmq, gevent-websocket and bottle as wsgi server. Though it works perfectly for one client, the other clients are waiting...

Read the entire recipe Recipe added 9 hours, 43 minutes ago

how to run knex migrations

I'm playing around with Ghost blogging platform https://github.com/TryGhost/Ghost/issues/769. It uses knex module for nodejs to interact with an sqlite3 database. The migrations to rollback look like this. I'm wondering if there's a way to run this...

Read the entire recipe Recipe added 10 hours, 43 minutes ago

Custom view/action/controller not working in Sails JS

I must be doing something wrong, but I can't see... Basically if I create a controller/model through sails generate controller products and in the file /controllers/ProductsController I add some variables to the index action such as:

index:...

Read the entire recipe Recipe added 11 hours, 43 minutes ago

How first perform the function and then send a static file

I have following code:

var express = require('express'),
    app = express();

app.use(express.static(__dirname + '/static'));

app.get('/', function(req, res) {
    //???
});

app.listen(80);

How first perform the function and then send a static...

Read the entire recipe Recipe added 12 hours, 42 minutes ago

Node.js server crashing without error message

I have a Node.js server that is continually crashing without logging any kind of error message. Is this a typical scenario? How can I trap the error and log it before it crashes?

Read the entire recipe Recipe added 13 hours, 39 minutes ago

NodeJS, Express server with ssl to use Dropbox API - 400 Bad Request

I'm currently at y-hack, hacking up an app. I've never deployed an app to a server before, but I've managed to create an AWS EC2 instance, I created ca certificates with startssl, and now I'm trying to retrieve information using the DropBox API.

My...

Read the entire recipe Recipe added 14 hours, 39 minutes ago

Is it necessary to use JADE when building Angular Apps with Node and Express?

Is it possible to build angularJS apps with plain HTML, ExpressJS on NodeJS ?

Read the entire recipe Recipe added 15 hours, 39 minutes ago

Javascript unfamiliar assignment construction

Sorry for basic question. I found the following construction in javascript and I not familiar with it. Do you know what is this construction?

I've changed the variables but the meaning is the same.

var pt = (
 5 in [1,2,3,5]?
 2:
 3 in [1,2,3]?
 1:
...

Read the entire recipe Recipe added 16 hours, 37 minutes ago

How to start programming something like mohiomap?

I'm thinking about creating a mindmap webapp for my own purpouses. I would like to incorporate a layout like they do at https://www.moh.io/mohiomap/welcome.php.

Can anybody give me any hints on how to start at something like this?

Regards,

Roel

Read the entire recipe Recipe added 17 hours, 37 minutes ago

String variable to stdin interface

I'd like to use the stdin parameter of this function: http://graspjs.com/docs/lib/.

The grasp function expects this parameter to be an object with the same interface that process.stdin. And what I have is a simple variable in memory of type...

Read the entire recipe Recipe added 18 hours, 40 minutes ago

Node + telnet + OS X

Good day.

var events = require('events');
var net = require('net');

var channel = new events.EventEmitter();
channel.clients = {};
channel.subscriptions = {};

channel.on('join', function(id, client) {
this.clients[id] =...

Read the entire recipe Recipe added 19 hours, 43 minutes ago

organize and display logs by modules on NodeJS

I am wondering if there is a way to organize and (un)activate logs on NodeJS.

Writing relevant logs takes time and comment/uncomment it is dirty and make us loose time.

I am looking for something close than the logs module, except i would like to be...

Read the entire recipe Recipe added 20 hours, 37 minutes ago

mongodb articles.length undefined

I am building a nodejs, express, mongodb blog, with jade.

My folder structure is: project/ modules/ views/ index.jade app.js articleprovider-memory.js articleprovider-mongodb.js

when I run...

Read the entire recipe Recipe added 21 hours, 41 minutes ago

Strange Date( )'s created with Strings containing NULL bytes

I know that JavaScript doesn't NULL terminate strings like C or C++ do, but I ran into a case which I can't explain.

Look at the following code (executed in Node.js v0.10.5) :

> new Date('123')

Fri Jan 01 123 00:00:00 GMT+0100 (CET) // UNIX epoch :...

Read the entire recipe Recipe added 22 hours, 36 minutes ago

Node.js Express | JQuery Nothing happens on client when getting a JSON

I want to receive on an HTML5 website JSON from a PostgreSQL database. So, on the server side I use node-postgres module for DB connection and also express module for communication.

The problem is that in the html i am not seeing any alert when...

Read the entire recipe Recipe added 23 hours, 37 minutes ago

Building syntaxhightlighter with nodejs in windows 7

I need to build Syntaxhighlighter from here: https://github.com/alexgorbatchev/SyntaxHighlighter

I have read these:
https://npmjs.org/doc/faq.html
Getting started with NODE.JS in windows x86
Get started with Node.js in Windows
Installing node...

Read the entire recipe Recipe added 1 day ago