How to use the BSONSymbol function from bson

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

62
63
64
65
66
67
68
69
70
71
72
/** @type {import('bson').ObjectId} */
module.exports.ObjectId = BSONJS.ObjectId;
/** @type {import('bson').BSONRegExp} */
module.exports.BSONRegExp = BSONJS.BSONRegExp;
/** @type {import('bson').BSONSymbol} */
module.exports.BSONSymbol = BSONJS.BSONSymbol;
/** @type {import('bson').Timestamp} */
module.exports.Timestamp = BSONJS.Timestamp;


// special case for deprecated names
fork icon0
star icon0
watch icon0

+ 12 other calls in file

142
143
144
145
146
147
148
149
150
  const expected = '{\n    ref: DBRef(\'coll\', \'57b80f922128ccef64333288\', \'\'),\n    ref2: DBRef(\'coll\', \'57b80f922128ccef64333288\', \'db\')\n}';
  expect(result).to.eql(expected);
});

it('should convert Symbol to string', function () {
  const test = { symbol: new bson.BSONSymbol('test') };
  const result = libBson.toString(test);
  expect(result).to.eql('{\n    symbol: {\n        value: \'test\'\n    }\n}');
});
fork icon0
star icon0
watch icon0