Tagged Questions
0
votes
1answer
44 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
26 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
15 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
28 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
30 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
32 views
What's the fastest way to create an API over a RESTful JSON interface for MongoDB? [on hold]
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
23 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
28 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
27 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
21 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
88 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
35 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
14 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
19 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
45 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 ...
0
votes
1answer
76 views
MongoDB - display different content based on username
I would like to implement a small application where users can register themselves and after the registration they can add items to a todo list. Essentially I am looking for ideas/tutorials on how to ...
0
votes
1answer
31 views
Case-insentitive find with mongoose using regular expressions
I'm using NodeJS with mongoose and my goal is to check if a pseudo requested by an user is not already in use.
I want to let users choose pseudos with uppercase letters, but I don't want an user to ...
0
votes
1answer
32 views
Mongoose query.select() Not functioning properly?
When defining a query with Mongoose, you can use:
query.select({somefieldname: 0}) // selects everything but 'somefieldname'
query.select({somefieldname: 1}) // selects only 'somefieldname' & ...
0
votes
1answer
46 views
Connecting MongoDB to the front-end?
I've built a database with Node.js and MongoDB, and I'm writing an Angular.js app that should call in entries from my database, as well as being able to write in those entries.
I'm aware that there ...
0
votes
1answer
24 views
Multiple criteria possible in one query inside MongoDB?
I've a "words" collection in MongoDB. When I want to search the collection I want to list first words that starts with the "word" and then contains the "word" that I querid. In the same array I get ...
1
vote
2answers
60 views
mongodb nodejs multiple insert issue
I'm trying to import a table from mysql to mongodb straight without any schema changes.
I wrote a small node script for that and my issue is with the way i implemented it.
Maybe I hit some limit of ...
0
votes
2answers
81 views
Jade JS doesn't output objects property, but outputs _id and __v fine? [fixed]
I am having an issue either with the Jade template engine, or something else I do not know. When I loop through an object and output it's properties, it doesn't seem to output the "country" property, ...
0
votes
1answer
20 views
Terminate mongodb connection in a callback
I'm just learning mongojs and nodejs so I'm still trying to get used to programming asynchronously. What my program should do is take input from a file ('list'), read each line and pass the line to a ...
2
votes
1answer
48 views
How to use closures in mongodb shell?
I'm kind of confused on how to use closures in mongodb shell.
I want to create a function that i can use exclusively during development to quickly look up a document by a part of it's _id.
The ...
0
votes
0answers
38 views
How/Where can I connect to mongodb to save a document from a js function?
I'm trying to create an app using mongodb, I'm not sure where to place the js file that controls the database, I'd like it so that my js working on the front-end can save documents to the database or ...
0
votes
1answer
28 views
Couldn't update docs in meteor, found a fix, but don't know how to use it. Where do I put it?
I hit a problem with updating docs with meteor mongodb. Found a fix here
meteor wont update data in mongodb
The solution comes with a piece of code, commented by the creator:
you could run this ...
0
votes
1answer
39 views
How to get a doc from a collection in meteor?
I am absolutely unexperienced with mongodb, so I am asking how to retrieve a document from a meteor collection.
I check if there is a doc for the user and update it with an object
if ...
0
votes
1answer
30 views
Add field that is unique index to collection in MongoDB
I'm trying to add a username field to documents in a 'users' collection, and I'd like it to be a unique index. (So far, we've been using email addresses for login but we'd like to add a username ...
0
votes
1answer
29 views
How to set mongo field from variable
for(var key in resp.updated_items){
Meteor.users.update({backend_id: Meteor.user().backend_id},
{$set: {'profile': {key: resp.updated_items[key]}}});
}
And this query set proper information ...
0
votes
1answer
42 views
How do I make searches on Mongodb using wildcard characters?
For example if my keyword is "all", I would like MongoDb to return all the documents in the given field containing the words "all" like "edgar allan poe" or "whitney hall". How do I do that in ...
0
votes
1answer
32 views
Mongoose ignoring part of object unless defined as Schema.Types.Mixed
Sorry for the coffee-script.
Pulling my hair out with this one. I have a schema similar to this:
reviewSchema = Schema
title: String
meta:
author: String
date: String
article: ...
1
vote
2answers
45 views
How to check NotEquals/Exists in Meteor Collection?
I'm trying to use a Meteor app to get documents from a mongodb database (using Meteor's Collection), but I only want documents that have a certain note field does not exist in it.
I tried to do:
...
0
votes
1answer
38 views
Meteor: How do I save to a collection and getdata out of it?
I am trying to make two function.
Save() should check if there is an existing document for that user, and if there is then update his save with a new one, and if there is not then insert a new doc ...
0
votes
1answer
23 views
Multiple connections with node-mongodb-native
I am working on a function to insert a document in a mongoDb database using the node-mongodb-native module. Everything is working, except if I call insert multiple documents back-to-back. I use a for ...
0
votes
0answers
24 views
Replica set initialization with a script
Im trying to automate sharding/replication a bit.
For that purpose I wrote a very simple script:
print("Init replica set")
rs.initiate()
print("Adding a new node")
rs.add("[not a local host]:7776")
...
0
votes
2answers
52 views
Meteor: How can I sort a collection on a session variable?
I want to write a helper method that returns a list of accounts-facebook based user profiles sorted on a sub-field of the profile document. The helper should rely on two session variables to specify ...
0
votes
0answers
30 views
How do I stringify a JSON date to a BSON readible date.
I am sending JSON data to a c# web service as a string that will then be deserialized by the C# mongoDB driver. The data is dynamic by nature and I will not know the shape of a given model beforehand ...
0
votes
0answers
38 views
Sending base64 string to node.js from PhoneGap not working
Currently I am developing a PhoneGap app and for this I have got a small upload app method created, which will take the base64 string of the picture and send it to the server ( AJAX ).
In the browser ...
0
votes
1answer
30 views
Mongoose For each element in loop
I am trying to loop through an array and add the items in the array to a mongodb database if it doesnt exist already. Inside the loop I try to query my database if the next element in the array is ...
0
votes
1answer
30 views
recursive find function calls then merge result
i cant merge the result of each FIND functions in this code :
this.result = [];
_products.find().exec(function (err,products) {
this.products = products;
var productsCollection = ...
1
vote
0answers
42 views
Ember JS + Ember Data: Sideloading doesn't work with string ids
I'm using ember rc3 and ember-data 12 (sha e324f0e) (basically the files recommended in the guides). I have 2 models set up as follows:
App.User = DS.Model.extend({
username: DS.attr('string'),
...
0
votes
2answers
43 views
Mongodb push to array but keep the array with a max of 3 items
Is there an easy way to push to an array in mongodb such that the array has no more than 3 items. If there are 3 items the push should throw out the first item in the array. I'm looking for a safe way ...
1
vote
1answer
74 views
MongoDb : How to insert additional object into object collection?
I have a document "owner" that can have "n" number of camps and camps have "instructors" and instructors have "classes". Earlier I tried accomplishing this with nested arrays (see link to my post ...
0
votes
0answers
18 views
Setting Mixed Schema Type Error
I've got an app that uses an older version of mongoose.js, and I've been in the process of upgrading it to 2.9.x (with the intention of upgrading to 3.x after this update is successful). It seems to ...
3
votes
1answer
80 views
Mongodb recursive search
I need to search through a collection of documents but also any subdocuments and rename a field titled "en" to "en-GB" in every occurrence, I have tried this code but keep getting a JavaScript ...
1
vote
1answer
49 views
MongoDB: Adding an array into an existing array
I'm trying to add an "Instructors" array into an already existing "Camps" array.
The hierarchical structure looks something like this:
owner = {
email : '[email protected]',
password : ...
0
votes
1answer
43 views
HOWTO: Produce mongoDB query string for the fields dynamically from a javascript app
I have a Node.js app with MongoDB
My customers collection schema is like this:
{
'_id' : 1234341264876876143 ,
'profile':{
'name': 'bob',
'email': '[email protected]',
...
0
votes
1answer
52 views
Display the data onto webpage retrieved from mongodb using node.js
Heres my problem. Might be a bit trivial. I am using node.js to write a form which has radio buttons, drop down boxes. I have been able to save data and also retrieve it successfully but I am not able ...