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