How to use the bson.Decimal128 function in bson

To help you get started, we’ve selected a few bson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brave-intl / bat-ledger / eyeshade / controllers / referrals.js View on Github external
runtime.database.checkIndices(debug, [
    {
      category: runtime.database.get('referrals', debug),
      name: 'referrals',
      property: 'downloadId',
      empty: {
        downloadId: '',

        transactionId: '',
        publisher: '',
        owner: '',
        platform: '',
        finalized: bson.Timestamp.ZERO,

        altcurrency: '',
        probi: bson.Decimal128.POSITIVE_ZERO,

     // added by administrator
        exclude: false,
        hash: '',

        timestamp: bson.Timestamp.ZERO
      },
      unique: [ { downloadId: 1 } ],
      others: [ { transactionId: 1 }, { publisher: 1 }, { owner: 1 }, { finalized: 1 },
                { altcurrency: 1 }, { probi: 1 }, { exclude: 1 }, { hash: 1 }, { timestamp: 1 },
                { altcurrency: 1, probi: 1 },
                { altcurrency: 1, exclude: 1, probi: 1 },
                { owner: 1, altcurrency: 1, exclude: 1, probi: 1 },
                { publisher: 1, altcurrency: 1, exclude: 1, probi: 1 } ]
    }
  ])
github brave-intl / bat-ledger / eyeshade / workers / wallet.js View on Github external
property: 'viewingId',
      empty: {
        viewingId: '',
        paymentId: '',
        address: '',
        paymentStamp: 0,
        surveyorId: '',
        // v1 only
        // satoshis: 0,

        // v2 and later
        altcurrency: '',
        probi: bson.Decimal128.POSITIVE_ZERO,
        mature: false,

        fee: bson.Decimal128.POSITIVE_ZERO,
        votes: 0,
        hash: '',
        timestamp: bson.Timestamp.ZERO
      },
      unique: [ { viewingId: 1 } ],
      others: [ { paymentId: 1 }, { address: 1 }, { paymentStamp: 1 }, { surveyorId: 1 }, { altcurrency: 1 }, { probi: 1 },
        { fee: 1 }, { votes: 1 }, { hash: 1 }, { timestamp: 1 }, { altcurrency: 1, probi: 1, votes: 1 },
        { mature: 1 } ]
    },
    {
      category: runtime.database.get('grants', debug),
      name: 'grants',
      property: 'grantId',
      empty: {
        grantId: '',
github brave-intl / bat-ledger / eyeshade / controllers / publishers.js View on Github external
settlementId: '',
        publisher: '',
        hash: '',
        address: '',

        // v1 only
        // satoshis: 1

        // v2 and later
        owner: '',
        altcurrency: '',
        probi: bson.Decimal128.POSITIVE_ZERO,
        fees: bson.Decimal128.POSITIVE_ZERO, // processing fees
        currency: '',
        amount: bson.Decimal128.POSITIVE_ZERO,
        commission: bson.Decimal128.POSITIVE_ZERO, // conversion fee (i.e., for settlement)
        fee: bson.Decimal128.POSITIVE_ZERO, // network fee (i.e., for settlement)
        type: '',
        executedAt: new Date(0), // When the settlement was executed
        timestamp: bson.Timestamp.ZERO
      },
      unique: [ { settlementId: 1, publisher: 1 }, { hash: 1, publisher: 1 } ],
      others: [ { address: 1 },
        { owner: 1 }, { altcurrency: 1 }, { probi: 1 }, { fees: 1 }, { currency: 1 }, { amount: 1 }, { commission: 1 },
        { fee: 1 }, { type: 1 }, { timestamp: 1 }, { executedAt: 1 } ]
    },
    {
      category: runtime.database.get('publishersV2', debug),
      name: 'publishersV2',
      property: 'publisher',
      empty: { publisher: '', facet: '', exclude: false, tags: [], timestamp: bson.Timestamp.ZERO },
      unique: [ { publisher: 1 } ],
github mongodb-js / bson-transpilers / codegeneration / javascript / Visitor.js View on Github external
executeJavascript(input) {
    const sandbox = {
      RegExp: RegExp,
      BSONRegExp: bson.BSONRegExp,
      // Binary: bson.Binary,
      DBRef: bson.DBRef,
      Decimal128: bson.Decimal128,
      Double: bson.Double,
      Int32: bson.Int32,
      Long: bson.Long,
      Int64: bson.Long,
      Map: bson.Map,
      MaxKey: bson.MaxKey,
      MinKey: bson.MinKey,
      ObjectID: bson.ObjectID,
      ObjectId: bson.ObjectID,
      BSONSymbol: bson.BSONSymbol,
      Timestamp: bson.Timestamp,
      Code: function(c, s) {
        return new bson.Code(c, s);
      },
      Date: function(s) {
        const args = Array.from(arguments);
github rueckstiess / mgeneratejs / lib / operators / decimal.js View on Github external
module.exports = function(evaluator, options) {
  // default options
  options = evaluator(
    _.defaults(options, {
      min: 0,
      max: 1000,
      fixed: 2
    })
  );
  return bson.Decimal128.fromString(
    String(
      chance.floating({
        min: options.min,
        max: options.max,
        fixed: options.fixed
      })
    )
  );
};
github mongodb-js / bson-transpilers / codegeneration / shell / Visitor.js View on Github external
NumberDecimal: function(s) {
        if (s === undefined) {
          s = '0';
        }
        return bson.Decimal128.fromString(s.toString());
      },
      NumberInt: function(s) {
github mongodb-js / extended-json / lib / modes / strict.js View on Github external
$numberDecimal: function(val) {
      return bson.Decimal128.fromString(val.$numberDecimal);
    },
    $maxKey: function() {
github Automattic / mongoose / lib / drivers / browser / decimal128.js View on Github external
/*!
 * ignore
 */

'use strict';

module.exports = require('bson').Decimal128;
github mongodb-js / query-parser / lib / index.js View on Github external
};

const FILTER_SANDBOX = {
  RegExp: RegExp,
  Binary: bson.Binary,
  BinData: function(t, d) {
    return new bson.Binary(Buffer.from(d, 'base64'), t);
  },
  UUID: function(u) {
    return new bson.Binary(Buffer.from(u.replace(/-/g, ''), 'hex'), 4);
  },
  Code: function(c, s) {
    return new bson.Code(c, s);
  },
  DBRef: bson.DBRef,
  Decimal128: bson.Decimal128,
  NumberDecimal: function(s) {
    return bson.Decimal128.fromString(s);
  },
  Double: bson.Double,
  Int32: bson.Int32,
  NumberInt: function(s) {
    return parseInt(s, 10);
  },
  Long: bson.Long,
  NumberLong: function(v) {
    return bson.Long.fromNumber(v);
  },
  Int64: bson.Long,
  Map: bson.Map,
  MaxKey: bson.MaxKey,
  MinKey: bson.MinKey,
github mongodb-js / query-parser / lib / index.js View on Github external
NumberDecimal: function(s) {
    return bson.Decimal128.fromString(s);
  },
  Double: bson.Double,