Пример #1
0
var get = exports.get = function(id, type) {
	var params = type.split("_");
	type = params[0];
	var d = dbapi[id].getJSON();

	var attachment = d["attachment"];
	if (attachment && attachment.length) {
		var infos = storage.getInfo(attachment);
		infos.forEach(function(d) {
			var k = d["k"];
			attachment[attachment.indexOf(k)] = {
				source: k,
				height: d.height,
				width: d.width,
				type: d.type
			}
		});
	}

	switch (type) {
		case "block":
			return {
				id: id,
				title: d["title"],
				content: d["content"],
				summary: d["summary"],
				attachment: attachment,
				user: d["userid"],
				created: d["created"]
			};
	}
}
Пример #2
0
	stat: function(id, e) {
		if (!getPower(id, "read")) {
			return {
				error: "noPower"
			};
		};
		return dbapi[id].inc("reads");
	}