var utils = require('../util/utils'),
	moment = require('moment'),
	_ = require('underscore');

exports.getBlog = function (req, res, callback) {


	var message = utils.messageFactory(),
		params = {
			blogToken : req.param('blogToken')
		};

	if (!params.blogToken) {
		throw(new Error('Blog token not submitted.'));
	}

	var sql = "SELECT\n" +
		"	AND blog.isActive = 1\n";

	utils.connection.query(sql,
		function (error, rows) {
			if (error) {
				utils.throwError(20, 'Blog retrieval error: ' + error, res);
				return;
			}

			var blog = {}
			rows.forEach(function (blogRow) {
				blog.blogToken = blogRow.blogToken;
				blog.name = blogRow.name;
				blog.shareCode = blogRow.shareCode;
			});

			message.data = blog;
			callback(message);
		}
	);
};
		"	blog.blogToken,\n" +
		"	blog.name,\n" +
		"	blog.shareCode\n" +
		"FROM blog\n" +
		"WHERE blog.blogToken = '" + params.blogToken + "'\n" +