How to use the DBRef function from bson

Find comprehensive JavaScript bson.DBRef code examples handpicked from public code repositorys.

42
43
44
45
46
47
48
49
50
51
/** @type {import('bson').Binary} */
module.exports.Binary = BSONJS.Binary;
/** @type {import('bson').Code} */
module.exports.Code = BSONJS.Code;
/** @type {import('bson').DBRef} */
module.exports.DBRef = BSONJS.DBRef;
/** @type {import('bson').Decimal128} */
module.exports.Decimal128 = BSONJS.Decimal128;
/** @type {import('bson').Double} */
module.exports.Double = BSONJS.Double;
fork icon0
star icon0
watch icon0

+ 12 other calls in file

133
134
135
136
137
138
139
140
141
142
});

it('should convert DBRef to string', function () {
  const test = {
    ref: new bson.DBRef('coll', new bson.ObjectId('57b80f922128ccef64333288'), ''),
    ref2: new bson.DBRef('coll', new bson.ObjectId('57b80f922128ccef64333288'), 'db'),
  };
  const result = libBson.toString(test);
  // eslint-disable-next-line max-len
  const expected = '{\n    ref: DBRef(\'coll\', \'57b80f922128ccef64333288\', \'\'),\n    ref2: DBRef(\'coll\', \'57b80f922128ccef64333288\', \'db\')\n}';
fork icon0
star icon0
watch icon0

+ 3 other calls in file