I'm using MongoJS in a Node project with Angular and trying to find documents based on a variable.
server.js
app.get('/api/find', function(req, res){
db.Fruits.find({code:'Apple'}).forEach(function(err, docs){
res.json(docs);
…
I have a large collection of data that I want to write a script against to read then process; in my case grabbing some fields and sending to a RESTful API.
To spare the load, I wanted to use limit and skip to paginate the data I retrieve and have…
I was trying to use findOne method. But it didn't show anything.It looks like it didn't execute. Would you like to help me solve this problem?
var mongojs = require('mongojs');
var databaseUrl = "mongodb:local:27017/mydb";
var db =…
I have been seeing tons of these FIND process. I am running nodejs with express and trying to poke the web service using POSTMAN. I have no clue what triggers these processes and this thing is slowing the server down.
While it does say something…
So I'm messing around with MongoDB using MongoJS and can't seem to get an error to be returned when a unique ID exists.
So this is the code I am using:
server.post('/register', function (req, res, next) {
var details = req.params;
…
Here is how I connect to my replica set with Node.js:
var MongoClient = require('mongodb').MongoClient;
var url = 'mongodb://ec2-54-237-60-17.compute-1.amazonaws.com:27017/test?readPreference=secondary';
MongoClient.connect(url, function(err, db)…
In case anyone else reads this, I've answered my own stupid question.
The problem was that I was storing the value as an integer, but searching for it as a string.
Pro tip: Store stuff as string values or;
When querying for a integer, while using a…
I'm using mongoDB(mongojs) and nodejs. When I run my server.js I get the following error. TypeError: Cannot call method 'find' of undefined
I do not know why is this happen.This is my server.js:
var express = require('express');
var app =…
I'm trying to keep a list of all the sites I'm working on right now, and I'm having issues using $push.
I've created a document with this:
accountData = {
'accountid': account_id,
sites: {
'001': 'example.com',
…
I can't seem to find the answer to this. I wan't a simple return statement of the amount (total) items in my collections.
var mongojs = require('mongojs');
var db = mongojs("myadb",['myadb']);
db.myadb.count(function(used,a){
…
I'm working with mongojs and writing tests for mocha running coverage with istanbul. My issue is that I would like to include testing db errors.
var mongojs = require('mongojs');
var db = mongojs.connect(/* connection string */);
var collection =…
I'm having some problems installing mongojs via npm. Whenever I try to install it (on windows 8) I just get a page full of red errors. There's so many of them that I don't even know where to begin, heres a sample of them (this is maybe 1/10 of total…
I am trying to find one record with "monogjs" by _id.
Our _id is a guid (.net).
So I have something like this "80cd95b8-79bf-4025-933b-cabc71fbdc9f" as a string.
Now I tried "monogdb.bsonpure" with a "buffer" specifying the subtype of uuid.
I tried…