Ejemplo n.º 1
0
    it('should convert Timestamp to string', function () {
      var test = {
        ts: mongodb.Timestamp(),
        ts2: mongodb.Timestamp(100, 100),
      };
      var result = bson.toString(test);
      var test2 = bson.toBSON(result);

      expect(test).to.eql(test2);
    });
Ejemplo n.º 2
0
  async function time() {
    if (ts) return (typeof ts !== 'number') ? ts : Timestamp(0, ts)

    const doc = await coll
      .find({}, { ts: 1 })
      .sort({ $natural: -1 })
      .limit(1)
      .nextObject()

    return doc ? doc.ts : Timestamp(0, (Date.now() / 1000 | 0))
  }
Ejemplo n.º 3
0
var Timestamp = function (high, low) {
  //Switch low/high bits to Timestamp constructor
  return mongodb.Timestamp(low, high);
};
Ejemplo n.º 4
0
  bar: { $regex: '[0-9]' },
  baz: { $regex: '[a-z]', $options: 'i' },
  $and: [
    { foo: { $undefined: true } },
    { bar: { $undefined: true } }
  ],
  bool: true,
  obj: { foo: 123 },
  string: 'foo'
}

var result = {
  _id: mongo.ObjectID(query._id.$oid),
  created: new Date('2013-01-01T00:00:00.000Z'),
  decimal: new mongo.Decimal128(Buffer.from('42.42')),
  ts: mongo.Timestamp(1412180887, 1),
  fkey1: new mongo.DBRef(query.fkey1.$ref, mongo.ObjectID(query.fkey1.$id.$oid), query.fkey1.$db),
  fkey2: new mongo.DBRef(query.fkey2.$ref, mongo.ObjectID(query.fkey2.$id.$oid)),
  binary: mongo.Binary(Buffer.from('foo')),
  minKey: mongo.MinKey(),
  maxKey: mongo.MaxKey(),
  numberLong: mongo.Long.MAX_VALUE,
  foo: undefined,
  bar: /[0-9]/,
  baz: /[a-z]/i,
  $and: [
    { foo: undefined },
    { bar: undefined }
  ],
  bool: true,
  obj: { foo: 123 },