module.exports = {
'init' : function(module){
var financials = new Schema({
key: { type: String, required: true },
value: { type: String, required: true },
isLabel: { type: Boolean, required: true, 'default': 0 },
idStaff: { type: ObjectId, index: true, ref: "staff" }
},{strict: true});
financials.plugin(useTimestamps);
var media = new Schema({
key: { type: String, required: true },
value: { type: String, required: true }
},{strict: true});
media.plugin(useTimestamps);
var companySchema = new Schema({
// Name of company
name: { type: String, required: true, trim: true, index: true},
// Ticker symbol of company
ticker: { type: String, required: true, trim: true, index: true},
// Description of the company
description: { type: String, required: true, trim: true},
// The analysts' view of the company's direction: http://bit.ly/y5ljYv
thesis: { type: String, required: true, trim: true},
footnote: { type: String, required: true, trim: true},
// Currency used to buy/sell shares in this company
floCurrency: { type: String, required:true},
// The estimated value of all assets and liabilities
fairValue: { type: String},
// Analyst's recommendation on whether to buy, sell or hold the stock
rating: { type: String},
numVisibility: { type: Number},
numCurrency: { type: Number},
// The potential dollar or percentage amount by which the market or stock could rise.
floUpsidePotential: { type: Number},
// Total dollar market value of all outstanding shares
floMarketCap: { type: Number},
// Market value (per share) / Earnings per share.
//
// High P/E suggests higher earnings growth in the future.
// The P/E is only useful relative to other P/E values in
// the industry.
floPriceToEarnings: { type: Number},
// A distribution of a company's earnings to a class of its
// shareholders. They may be in the form of cash,stock or
// property.
numAnnualDividendsPerShare: { type: Number},
// Array of sectors a company is assigned to.
idSector: [{ type: ObjectId, index: true,ref: "sector"}],
// Arrage of countries a company is assigned to.
idCountry: [{ type: ObjectId, index: true,ref: "country"}],
isActive: { type: Boolean, required: true, index: true, 'default': 1},
financials: [financials],
media: [media]
},{
strict: true
});
companySchema.plugin(useTimestamps);
var model = mongoose.model(module.moduleName,companySchema);
return model;
}
};