{"size": 1358, "ext": "js", "max_stars_repo_path": "models/tick.js", "max_stars_repo_name": "somenano/api.marketcapcompare.com", "max_stars_repo_stars_event_min_datetime": "2021-06-18T04:48:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-18T04:48:16.000Z", "max_issues_repo_path": "models/tick.js", "max_issues_repo_name": "somenano/api.marketcapcompare.com", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "models/tick.js", "max_forks_repo_name": "somenano/api.marketcapcompare.com", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.5555555556, "max_line_length": 80, "alphanum_fraction": 0.5913107511}
var mongoose = require('mongoose');
var mongooseLeanVirtuals = require('mongoose-lean-virtuals');

var js_helper = require('../helpers/js.js');

var Schema = mongoose.Schema;

var TickSchema = new Schema({
    dtg: {
        type: Date,
        default: Date.now,
        required: true
    },
    symbol: {
        type: String,
        required: true
    },
    price: {
        type: Number,
        required: true
    },
    marketcap: {
        type: Number,
        required: true
    },
    volume_24h: {
        type: Number,
        required: true
    },
    reddit_subs_total: {
        type: Number,
        required: false
    },
    reddit_subs_active: {
        type: Number,
        required: false
    }

},{
    versionKey: false,
    toObject: { virtuals: true },
    toJSON: { virtuals: true }
});

TickSchema.virtual('symbol_lower')
    .get(function() {
        return this.symbol.toLowerCase();
    });

TickSchema.virtual('time_bucket')
    .get(function() {
        // console.log('time_bucket called ' + new Date(this.dtg).YYYYMMDDHH());
        return new Date(this.dtg).YYYYMMDDHH();
    });

TickSchema.virtual('time_identifier')
    .get(function() {
        return js_helper.getTimeIdentifier(this.time_bucket, this.symbol);
    });

TickSchema.plugin(mongooseLeanVirtuals);

module.exports = mongoose.model('tick', TickSchema);