What is the best way to provide code samples for my NodeJS application that uses mongo via mongoose.
I am dealing with a problem where I want to post a working example of some schemas & models that requires DB access.
I was hoping for something like jsfiddle but could not quite figure out how to use that for what I wanted.
Yes, I'm a noob... Thanks!
Why don't you try the reliable service of c9.io?
I haven't tried using Mongoose there, but it shouldn't be much of a magic.
Related
I'm about to develop an application in MEANJS. Now I think it would be a nice thing to change the mongodb connection, at least the schema, programatically.
The reason why I'm thinking about this is, so I can have seperate and different data, by driving the same application code.
I read the API documentation for mongoose, but didn't find anything about this.
Has anyone done this or something similar, or has a better suggestion?
Thanks in advance.
Markus
I have a one file which has details of the database named xyz.js and another file which created the database using that file in mongodb and also has various functions like adding to database etc.The name of this file is create.js. Now I want to convert create.js code using mongodb to waterline.
me_aj, there is no possible short and simple answer for what you want. Nor there is any tool that will do what you need. Here are some pointers for what you'll need to do.
1. Learn about using waterline
It may sound obvious but you should start by getting acquainted with waterline and the best places are the waterline project and the Waterline Docs.
By then you'll know waterline is an adapter based ORM and that you'll have to decide which adapter to use. If you are using mongodb, you are probably looking at sails-mongo.
2. Config waterline to connect to the desired data store
Waterline, contrary to some other ORMs, has to be initialised before you can start using it. If you are using it outside sails you should look at these examples on how to set up a simple app. You'll also need to configure it by following the specific adapter settings. If you are connecting to mongodb check the instructions on the sails-mongo project.
3. CRUD operations
By now you've setup waterline to initialise and connect to your chosen data store, now it's time to do things with it. Similar to many other ORMs. waterline uses methods such as find, update, create and destroy to perform CRUD operations, to learn more about using these check the query methods documentation page.
This should be enough to point you in the right direction.
I have seen alot of examples of how to integrate express.js and mongodb. Does anyone know a good way to integrate neo4j and express.js?
I have been playing around with node-neo4j and I am able to return cypher queries to the terminal. However, I am confused as to how to post the cypher query, in json format, to the local host.
Thanks for your help.
In order to reply simply to your question, there is an express module for Neo4j, here :
http://expressjs.com/guide/database-integration.html#neo4j
It will remove you the burden to format the json correctly for preparing the statements.
Repository is here if you want to see how it is used inside :
https://github.com/hacksparrow/apoc
Maybe you can contribute to it, for the quick look I did, I see that there is no support for 2.2 auth extension, so you may want to make a PullRequest in order to improve the library.
What is the optimal way to perform CRUD operations when using Node.js with MongoDB. Can I reuse the same queries that work on mongo shell? What advantages does a ODM like mongoose provide? Any other ODMs which fit into the mean.io stack?
vmr.
Well, I guess it depends of what you want to do.
Lets take what Mongoose says in their website:
Mongoose provides a straight-forward, schema-based solution to modeling your application data and includes built-in type casting, validation, query building, business logic hooks and more, out of the box.
Resuming what I understood of that it helps you to model your database and helps you to mantain your logic organized using model like in an MVC. It's a very mature ODM and very recomended for using with MVC.
In my personal experience I started using Monk, which did the trick for a while, but the I started to need to use aggregate and other stuff that apparently Monk can't handle. And I don't wanted to tie my system to an model because is a very mutable project, so I started using Mongoskin which is, at least for now, perfect for me because I can use pratically the same query that I use at Robomongo (Which is like a Navicat, PgAdmin, PhpMyAdmin but for MongoDB) in my ExpressJs code.
Mongoose is saving your time by mapping the JavaScript Data objects to the MongoDB database.
MongoDB and NodeJS Integration
Is it possible to use dc.js with node.js, and if so how? I would like to provide an example, but it's hard to see how to start on this, and no working examples seem to be available online.
In short, yes.
I have implemented a full fledged app using nodejs and dc while the document store was mongo. The nodejs server is used for fetching the data from mongo db and serving it as api. Dc.js then uses this data for rendering charts.
I will write a blog post about it and post it in a couple of days. In the meantime do let me know if you have any more queries.
Updated:
Here is the link to the blog post.Do share if you find it useful.
https://anmolkoul.wordpress.com/2015/06/05/interactive-data-visualization-using-d3-js-dc-js-nodejs-and-mongodb/