Sha256: 5139f479cbfffb7706dbaacb24aa18dbfe2ed2e71c56473f874008242eb6efb6
Contents?: true
Size: 642 Bytes
Versions: 3
Compression:
Stored size: 642 Bytes
Contents
const mongoose = require('mongoose/browser'); 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
3 entries across 3 versions & 1 rubygems