Sha256: c8c8216fdc5dc25c9c95220e64800220648e1e5743ebe23e50ebb9ae0c2ee56d
Contents?: true
Size: 608 Bytes
Versions: 4
Compression:
Stored size: 608 Bytes
Contents
const mongoose = require('mongoose'); const cql = require('cql-execution'); function Ratio(key, options) { mongoose.SchemaType.call(this, key, options, 'Ratio'); } Ratio.prototype = Object.create(mongoose.SchemaType.prototype); Ratio.prototype.cast = (ratio) => { if (typeof ratio.numerator === 'undefined') { throw new Error(`Ratio: ${ratio} does not have a numerator`); } else if (typeof ratio.denominator === 'undefined') { throw new Error(`Ratio: ${ratio} does not have a denominator`); } return new cql.Ratio(ratio); }; mongoose.Schema.Types.Ratio = Ratio; module.exports = Ratio;
Version data entries
4 entries across 4 versions & 1 rubygems