Tagged Questions
0
votes
0answers
17 views
encapsulate data repository with mongoose -> strange behavior
I am trying to hide away my database persistence from my business logic. I am implementing right now a persistence layer with mongo but I would like to make it exchangeable (in the future). In my real ...
0
votes
1answer
15 views
How to terminate earlier a MongoDb shell script?
Writing:
if (...) {
return;
}
in a MongoDb shell script will complain: SyntaxError: return not in function
I have also tried the exit mongo console command:
if (...) {
exit;
}
but you ...
2
votes
1answer
52 views
Pushing changes to deployed Meteor.js app
After deploying a meteor.js app to my own server, what is the best practice to continue pushing code changes to the live app if I want to develop off the server?
Do you upload the newly edited file ...
0
votes
1answer
35 views
In Meteor.js, Why is this.userId == undefined?
I'm learning Meteor by following a book, and right now we want to insert() the userId of the user that is currently logged in.
Template.categories.events({
'keyup #add-category': function(e, t) ...
0
votes
0answers
38 views
MongoDb map-reduce exception
I have the following prototype:
{
"_id" : "Nwva",
"cat" : {
"_id" : ObjectId("4ffee943e4b08a66fd8e84a1"),
"slug" : "fun"
},
"imp" : false,
"int" : {
"comm" ...
0
votes
2answers
23 views
How to properly add HOST using sails-mongo adapter?
I've installed sails-mongo through npm and have a basic sails.js application running
but it's not recognizing my host.
MongoDB is up and running on the default port 27017 but after I generate a ...
0
votes
3answers
69 views
Loop is not outputting true or false based on query
please take a look and let me know why the loop's output is not correct?
Basically I am looping through the friendId array of a user and through the user results for a search and seeing if they match ...
0
votes
3answers
46 views
Closures to get variable in node.js
Can anyone help me urgently for my Thesis software for get variable in closures..
this is my code in node.js
var kepala = express.basicAuth(authentikasi);
// authenticate for login
function ...
0
votes
1answer
41 views
MongoDB Cursor has no method 'next'
These work fine:
myCollection.find();
myCollection.findOne();
This does not:
myCollection.find().next();
^
TypeError: Object #<Cursor> has no method ...
0
votes
0answers
32 views
Node.js app.post does not populate MongoDB?
I'm running Node.js, Express, Mongoose and Mongodb locally and have this code in my app.js:
var express = require('express');
var app = express();
app.use(express.bodyParser());
// Decaler Mongoose
...
0
votes
1answer
24 views
Efficient text search with mongo node and express, ajax call
I am trying to re-create the 'facebook', 'twitter', etc, search bar, that looks up users and other pages in the database, and serves the links to them.
For example if I have a user with a name ...
1
vote
1answer
18 views
MongoDB: $push into an array based on a variable's contents
I'm trying to $push an item into my record in MongoDB built on Node (using MongoJS), like so:
exports.saveToUser = function (req, res) {
console.log("IN");
var user = req.params.user;
...
0
votes
1answer
71 views
Why variable shows up as undefined?
I am querying a user in a friend request array which works, but the check which I am using userAdd for keeps showing up as undefined. Anyone know why it is showing up as undefined?
This is the code:
...
0
votes
2answers
37 views
Update subarray of strings
I'm trying to update item in subarray of document. Type of subarray is array of strings:
Dictionary.findOne({ name: req.query.name }, function(err1, data){
if(err1){
...
0
votes
0answers
36 views
What to store on Redis, what to store on Mongo? [on hold]
I have a web service, and I'm trying to push as much of my persistent data to Redis for obvious performance reasons. I already have portions of my node.js application using Redis for storing child ...
0
votes
0answers
46 views
How do I loop through the search results and based on which ids match return true to display different info for it?
Hey so I am trying to search through the search results and see who already exists in the friendRequest array of the user searching. If they exist then I want to change the button that displays for ...
0
votes
0answers
65 views
Not able to disable button
So I am trying to have the add contact button disabled if the user.id already exists in the friendRequest array. However, for some reason the code is not working the way it is suppose to, and nothing ...
0
votes
1answer
24 views
how to update into nested in array in mongodb
i have a structure like this
{
"name":"xxxxxx",
"list":[
{
"listname":"XXXXX1",
"card":[
{
...
0
votes
0answers
29 views
How to call get on a button?
How do you call a get on the add friend button to disable the button in jquery if the friend request was already added to the friendRequest Array?
I included my take on it, but not sure what I am ...
0
votes
0answers
22 views
How do I avoid duplicates friend requests in the db?
I am getting the correct data for friendRequests which is getting a user ID and throwing it in the friendRequest array. How do I stop duplicate requests or better yet just disable the button for a ...
0
votes
0answers
16 views
Echo mongo db queries from javascript web application to server
I would like to write a web app in Javascript that can access mongodb records, both inserting and finding, via AJAX calls.
One way to do this would be to use a Drowsy Dromedary or one of the other ...
0
votes
1answer
27 views
How to push returned value into an array mongodb?
I am getting the correct data for friendRequests which is getting a user ID and throwing it in the friendRequest field of my mongoose file. When I add $push to add the data into the friendRequest ...
0
votes
1answer
45 views
How to pass data from jade to mongodb using NodeJS as the server language
I'm using NodeJS, Express, MongoDB, Mongoose and jade for the web app.
I am wondering how I pass data from jade to mongodb. The data that I want to pass are texts inside certain divs that are appended ...
0
votes
0answers
40 views
mongoose functions only working on second call
So the weirdest thing is going on. I have a coffeescript class which I use to construct a mongoose schema.
module.exports = class Profit
constructor: (Schema, mongoose) ->
...
0
votes
0answers
46 views
Cannot figure out what I am doing wrong with add friend button
So I am trying to figure out how to make an add friend button. I am using Node.JS to route a POST with Jade as my view engine showing an input button in a form that is just an add Contact button. ...
1
vote
1answer
23 views
mongodb updating only specific subelements
my db structure looks like:
{
"_id" : ObjectId("51e66873f6a6600436000001")
,"email" : "[email protected]",
,"attribute_group_a" : {
"attribute_a" : ""
,"attribute_b" : ""
,"attribute_c" ...
0
votes
0answers
40 views
Onclick populate a model that contains multiple sub models in nodejs
My setup is:
var mongoose = require('mongoose');
var Schema = mongoose.Schema
, ObjectId = Schema.ObjectId;
var Sub = new Schema({
id: String,
content: String,
Date: Date
});
...
2
votes
2answers
67 views
Best session storage in ExpressJS - NodeJS
I'm building my first (and rather big) NodeJS application. I need excellent performance since it's a big all AJAX (AngularJS) interface with a lot of requests from a lot of users.
I'm building the ...
0
votes
3answers
24 views
How to extract an array of elements from an array of JSON documents to use in a mongodb query?
I know the question is quite wordy and complicated, so let me explain.
I have 2 mongodb collections, stu_creds and stu_profile. I first want to retrieve all the student records from stu_creds where ...
0
votes
1answer
20 views
Ordering flow in asynchronous logic with long-ish callbacks
The basic flow of this program is to receive UDP packets, look up some info on them, then send them off for further processing. The info is currently stored in mongodb.
Pseudo-JS is something like:
...
1
vote
2answers
51 views
Meteor.js / MongoDB : finding a document's place in a collection
Solved thanks to Hubert OG!
I have a collection with a popularity property and i do a:
var x = collection.find({},{sort: {popularity: 1}})
and then i want to find the position (index) of a ...
0
votes
1answer
23 views
How to create an ObjectId from a Date value in the mongo shell?
I want to create a new ObjectId in the mongo shell but for a Date in the past in order to simulate the creation ob this document in the past. That would be the opposite of the getTimestamp() function ...
0
votes
2answers
29 views
Variable suddenly becomes undefined in the callback to an Angular $resource function
I'm building a function in Node that queries my mongoDB database and returns some results into an object. I'm having trouble getting the object set up correctly though. Here's my code:
Function to ...
0
votes
1answer
50 views
How do you avoid a crash if someone tries to access a page without loging in?
Hey so when I try to go to a page that cannot be accessed without logging in, the app crashes. How do I avoid this? The reason why it crashes is because when they try to access that page, the page ...
1
vote
1answer
31 views
How can I modify the documents on an object-level in find() before I publish them?
I would like to modify the documents matched in the find() cursor in my publish method. However, it should not be saved into Mongo.
Example:
Email.find({}) returns a document like
{email: ...
0
votes
0answers
20 views
node + express + mongoose query authentification
Im building a simple web app app in express, and I'm a bit stuck in the authentification for my sessions, im going to validate everything in the client with backbone and regExp eventually when i start ...
0
votes
2answers
37 views
Async and recursion in nodejs
Beginning with express and mongoose i often need to do some batch operations on collections.
However it usually involves callbacks which is a pain given how concurrency is coded in nodejs.
so ...
0
votes
1answer
24 views
what's wrong with this model
I need to develop a module for getting data from mongodb, I already have other models working in my application, but this one does not, this is my schemas:
var mongoose = require('mongoose');
var ...
0
votes
1answer
34 views
Case insensitivity when searching MongoDB - is eval() ok?
I have lots of records stored in MongoDB, and they're (mostly) written in title-case. Sample prototype:
{
'name':'Awesome Pair of Jeans',
'designer':'Company123',
'description':'This pair of ...
3
votes
2answers
50 views
Ordering by several keys in MongoDB
I would like to order a collection based on several keys. E.g.:
db.collection.find().sort( { age: -1, score: 1 } );
This is all fine and dandy. However, I would like to guarantee that age comes ...
0
votes
1answer
36 views
What's the fastest way to create an API over a RESTful JSON interface for MongoDB? [closed]
My technical experise is restricted to Javascript and Python.
How can I create an API for MongoDb that I may use with my client side Javascript MVC framework?
0
votes
1answer
24 views
Search MongoDB to return all values for a parameter
I'm running an app built with Angular, built on a Node/Express/MongoDB stack.
In my Mongo database, I have objects that look like this:
{
"infoLink" : "http://foo.com",
"name" : "Fossil ...
0
votes
2answers
39 views
updating a live mongoose js application
I have a very basic question, I tried google but I cant really find anything.
I'm trying out mongoose js and I was wondering how you go about updating a live application.
Say for example I have ...
0
votes
0answers
29 views
Get index of $in iterator in MongoDB query
I have an array that is returned from a
.find(...).toArray(function(e,o){...}
and then I am trying to iterate over this array by querying another database using the $in keyword. Is there a way I ...
0
votes
1answer
26 views
Mongojs print and console.log not working
I am running the following command and I want to see the output in my out.log file but it is not printing anything.
/tmp/mongodb/bin/mongo mydatabase_name /tmp/mongodb/scripts/test.js >> ...
1
vote
2answers
102 views
Does server-side javascript function have performance issues in mongoDB?
Does running server-side JavaScript have performance issues in MongoDB? Does V8 solve said performance issues?
Why does the MongoDB documentation recommended not using server-side functions?
0
votes
0answers
39 views
How to keep values from reverting back to default during update in mongoose
I have a mongo document with some default behavior
var thingSchema = new mongoose.Schema(
things:
first: {
type: Boolean,
default: false
},
...
0
votes
1answer
18 views
Correct way to search for MongoDB entries by '_id' in Node
I'm using MongoDb (as part of MongoJS) in Node. Here is the documentation for MongoJS.
I'm trying to do a call within Node based on an entry's _id field. When using vanilla MongoDB from the console, ...
0
votes
1answer
22 views
A PHP script for MongoDB accent search needs to translate into JavaScript
I found a PHP script that let to find text in some accent characters. My project is nodejs+mongodb so I tried to translate JavaScript but I couldn't be able to translate it at all. Since I don't know ...
1
vote
2answers
48 views
Simple db mongo query gone wrong?
Hey I am trying to query the database (mongodb) from my index.js file then return the value from the query into a variable so I can then use that variable to show the persons information on the ...