I want to preface this with saying that I really like sails.js for a simple MVC framework, but feel that it lacks in its documentation and api reference.
I searched all over to try and find any information on a good mssql (SQL server) adapter for Sails.js, but cannot find one. I am hoping someone has come across one, and could recommend it. I also looked into building a custom adapter, but found the documentation to not be helpful. Any help on this topic would be greatly appreciated. Thank you.
We don't currently have a MS SQL Server adapter but it's something I'd love to add. There is a basic definition of the various interfaces and how adapters are created at: API Adapter Interface.
If anyone would like to tackle this you can use the Sails MySQL Adapter or the Sails PostgreSQL Adapter as examples.
I don't have access to a MS SQL Server to build one out but there is an Integration Test library I use to build out adapters that support the CRUD interface: Waterline Adapter Tests.
I have recently started building a sails adapter for MSSQL based on the node-sqlserver module.
It isn't finished yet but I have finished the main parts of the adapter and it still needs testing, but there is enough there to get going.
It can be found at https://github.com/swelham/sails-mssql
There is now: https://github.com/cnect/sails-sqlserver
Complete with sails 0.10 associations support, and fully unit tested against the Waterline spec:
Technically since Sails is base on express.js you could use custom express middleware to specify the use of your an adapter that has already been created.
The first one is the top rated adapter
checkout https://nodejsmodules.org/tags/mysql
Otherwise you can just use the waterline ORM and the MySQL adapter that is provided for sails.js
https://github.com/balderdashy/sails-mysql
For documentation on how to use waterline models checkout the 0.9x docuemntation
http://sailsjs.org/#!documentation/models
sails-mssql is working fine for me on 0.10.x, here's a gist of how to configure it, using sails-mssql 0.10.x
https://gist.github.com/hybrisCole/868f979d8d129247a2da
my package.json has this:
"sails-mssql": "git://github.com/jaredfromsubway/sails-mssql.git#master",
Sails-sql is currently the latest adapter for MySQL/MSSQL (eventually PostgreSQL as well). It's currently safe, fine-tuned, and upgraded for use in production with MySQL and MSSQL. Most developments are primarily pending for PostgreSQL at the moment.
Another current option is https://www.npmjs.com/package/sails-mssql (https://github.com/intel/sails-mssql).
Related
I'm currently writing a program that is a To-Do list that just runs locally on my machine in the terminal screen(written in node.js, no extra dependencies). I've set up everything and it works totally fine, but I have never actually used any databases other than just session cookies on the browser. What would you all suggest I use when all I want to do is learn how to store some simple data in a database and then be able to manipulate it in the same fashion.
Any help would be greatly appreciated on this one! I'm really just looking for suggestions on a good database, as well as a bit of guidance on the best way to use that particular technology. I'm familiar with SQL and NoSQL databases, but like I said, I have never even used one on an actual application.
Thanks in advance.
In my view, You can use mongodb which is easy to configure and manipulate data. It helps you to work on json objects directly from database. Use express to create your RESTful endpoints and exposed data. Sometime back i use it for angular application, repo link is below for your reference :
AngularJs, ExpressJs, MongoDB application
Hope this helps.
Cheers
You can use sqlite which provides a good SQL API but keeps things very simple by simply using a file on your disk and accessing it through code directly in your application. You don't need to start another server and take care of configuring it.
For a simple To-Do list that should be more than adequate for storing your data whilst keeping your configuration simple and easy.
Here's a tutorial on how to set it up:
http://www.sqlitetutorial.net/sqlite-nodejs/
You'll essentially be using the sqlite3 npm package: https://www.npmjs.com/package/sqlite3
That page also comes with brief usage instructions.
Nodejs has client libraries for database interaction
Ex.
For SQL database:
postgresql : https://github.com/brianc/node-postgres
For NoSQL db:
mongodb : https://github.com/Automattic/mongoose
You can also create pool of db connections
I'm working on an Open Source microservice based project in Node.js.
Description of the problem
Some microservices are so thin and only interact with MongoDB, so I haven't used Sails there and preferred using Mongoose directly. Thus, I've implemented mongoose schemas for each of the objects I need to persist in mongo.
I'm also going to have Sails.js in some other microservices, Therefore I'll have to implement Waterline-type schemas for the objects I want to persist & query there.
The problem is the duplication of schemas, which I find useless.
Solutions I thought of
I wish to use one type of schemas across all the services.
There are 3 options now:
A magic method to connect between the schemas (which I'm not aware of), and have both worlds work simultaneously (least probable option).
To use Waterline across all the microservices, whether I use Sails.js or not, therefore have 1 schema type in the system.
To force Sails.js to use mongoose adapter instead of Waterline, and then implement some CRUD Data Access Layer (DAL) which uses Mongoose internally, and use it everywhere to access the DB.
Therefore the Mongoose schemas will be across all the system. But then I give up on the Waterline encapsulation capabilities, and if in the future I'd like to change DB, I'll be in trouble.
I could also compromise and duplicate schemas in my app, but that's the last resort as I believe there has to be some solution to this problem.
Whoever consider Waterline vs Mongoose... right to this date, choose Mongoose.
Waterline made us so much head-ache, while mongoose is so smooth and straightforward.
I could think of the following to go fully Sails:
put the common parts, like the Sails models, in a Sails project and push it to a (private) npm package
use https://github.com/tjwebb/marlinspike or other sails hooks to import them in every instance you need it.
I have not tried this, but preparing for similar steps in the future.
Also, I saw this issue: https://github.com/tjwebb/marlinspike/issues/4
I have done considerable reading on both Node.js and Backbone.js; I've read some tutorials and done the relevant courses on Code School. I feel that I've got a pretty good idea of the functions that each technology serves in the context of a web application.
My problem is that I don't really know how to integrate the two technologies and use them in tandem. I would really appreciate if someone could point me to a resource which goes through the entire development of an application using Node, MongoDB, and Backbone together.
Many thanks
This is a good tutorial that shows how to setup that entire stack.
http://backbonetutorials.com/nodejs-restify-mongodb-mongoose/
In short...
Node.js
You can use a library like restify to provide a restful API for your client-side Backbone application. It can also serve your static assets for your Backbone application. The example uses restify, but could be accomplished with other libraries like express.
Mongoose
Mongoose is a javascript abstraction layer for MongoDB. This provides an easy way to interact with MongoDB from Node.js.
Backbone
Your Backbone application can utilize your restify node.js backend to handle the model synchronization. You should have plenty of control to setup the routes via restify in a way that makes Backbone happy.
This ebook could be useful (it's on Backbone, but uses Node for the backend):
http://addyosmani.github.io/backbone-fundamentals/
You also may want to look at this book:
http://www.amazon.com/Building-Node-Applications-MongoDB-Backbone/dp/1449337392
There is also Node Cellar Source.
There is not much explanation about the code, but the app is simple enough to get started and understand the basics layouts of node / backbone
It is, i think, just between an 'Hello World' code and a full app.
I use for ap in backbone yeoman https://github.com/yeoman/generator-backbone and you use it with node.js too
create rest api: http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/
code backbone on the client: http://coenraets.org/blog/2012/10/nodecellar-sample-application-with-backbone-js-twitter-bootstrap-node-js-express-and-mongodb/
the backbonetutorials.com restify one is out of date. It's best to use express, especially if you plan to do any authorization. It's also more widely used
This is a comprehensive tutorial on rolling your own blog with Nodejs, Mongodb and expressjs
http://howtonode.org/express-mongodb
It's old but with a little effort you can get it to work and learn at the same time
I have found this to be the most up to date material on using Backbone.js with node
http://amzn.to/1DygKlJ
I've been trying to do some research on node.js and Mongodb and have a few things that need clarifying.
I'm trying to query Mongodb from the web and want to use JavaScript because I'm familiar with the language, plus it makes sense because that's what Mongodb uses in the command line interface.
It seems that I'll have to use node.js to query mongo from the web, but what I can't find info on is a way to tell my node.js server what I want to query, from the web.
If someone can point me in the proper direction ( reading material, how to, examples) that would be awesome.
Here's some articles I used...
http://css.dzone.com/articles/nodejs-and-mongodb-beginner%E2%80%99s-0
http://srirangan.net/2012-02-node-js-and-mongodb-getting-started-with-mongojs
http://mattkopala.com/blog/2012/02/12/getting-started-with-nodejs/
I found Mongoose to be the best Node.js MongoDB library (the creator of Mongoose actually now works for 10gen, the company behind MongoDB).
Besides a lot of good examples on the official Mongoose website, you can find lots of other resources:
http://pixelhandler.com/blog/2012/02/09/develop-a-restful-api-using-node-js-with-express-and-mongoose/
http://backbonetutorials.com/nodejs-restify-mongodb-mongoose/
http://dailyjs.com/web-app.html (how to build an app from the start, multiple lessons)
One of the most important things I like about Node.js and MongoDB (Mongoose in my case) is that you are writing the query commands sometimes exactly like you write them in the MongoDB shell.
P.S. Last but not least, checkout the videos from 10gen related to Node.js and MongoDB, there are lots of them (and people using Node with Mongo in production): http://www.10gen.com/presentations#programming_lang__javascript_nodejs
I'm used to developped on ruby mainly using RoR and deploying on heroku. I'd like to find out if a similar environment exists for node.js. I saw nodester.com (I'm still waiting for my coupon) but it seems there is no underlying database. Would you recommand a specific DB to work with node.js ?
Also, is there a kind of framework like RoR that could provide ORM capabilities (like ActiveRecord) ?
I started work on ActiveRecord implementation of MySQL for NodeJS on GitHub a while ago. It uses node-mysql module and the interface is similar to ActiveRecord class of CodeIgniter (a PHP framework).
Would you recommand a specific DB to
work with node.js ?
MongoDB or Redis, but it depends on your use case.
Also, is there a kind of framework
like RoR that could provide ORM
capabilities (like ActiveRecord) ?
Try to look at Express and mongoose.
Also check out a list of node.js modules.
Being that node is supported by Joyent (and some of the primary developers are employed by Joyent), you might want to look to them for hosting options: https://no.de/
Express is the primary framework in the land of node right now, but I'm not sure that ActiveRecord and Mongo are the happiest of pairs, you might want to look at MySQL options for node at that point. Something like noblerecord might work for you: https://github.com/noblesamurai/noblerecord
Check this:
Web application framework partial.js:
https://github.com/petersirka/partial.js
Async web framework
Simple view system
Simple routing
Supports simple CouchDB provider
Supports simple ORM (via HTTP-RDBMS)
https://github.com/petersirka/http-rdbms/