Sha256: 5a04f7c8f44b37069123520a183f05995716b73ff648af5b4bc8f961d2ee53ea
Contents?: true
Size: 663 Bytes
Versions: 16
Compression:
Stored size: 663 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.value, quantity.unit); }; mongoose.Schema.Types.Quantity = Quantity; module.exports = Quantity;
Version data entries
16 entries across 16 versions & 1 rubygems