Page MenuHomeSealhub

resource-representation.js
No OneTemporary

resource-representation.js

/**
* Represents a particular resource in database. Constructed by database entry.
* @class
* @param {object} database_entry
*/
function ResourceRepresentation (database_entry) {
this.database_entry = database_entry;
}
ResourceRepresentation.prototype = new function(){
/**
* Returns an object representing the resource, ready to be output for the public, e.g. as JSON
* @alias Resource#getData
* @return {object}
*/
this.getData = function(){
var data = this.database_entry.body || {};
data.owner_id = this.database_entry.owner;
data.id = this.database_entry.sealious_id;
data.access_mode = this.database_entry.access_mode;
data.type = this.database_entry.type;
return data;
}
/**
* Encodes Resource's data into JSON
* @alias Resource#toString
* @return {string} contains the json-encoded data
*/
this.toString = function(){
return JSON.stringify(this.getData());
}
/**
access_mode are not used in current version of Sealious, this code should be removed
*/
this.get_access_mode = function(){
return this.database_entry.access_mode;
}
}
module.exports = ResourceRepresentation;

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 10:45 (22 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
556419
Default Alt Text
resource-representation.js (1 KB)

Event Timeline