How to use the EJSON function from bson

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

4
5
6
7
8
9
10
11
12
13
14
const bson = require('bson');
var debug = require('debug')('mongodb-query-parser:test');


function convert(string) {
  var res = parser.parseFilter(string);
  var ret = bson.EJSON.serialize(res, { legacy: true, relaxed: false });
  debug('converted', { input: string, parsed: res, encoded: ret });
  return ret;
}

fork icon9
star icon35
watch icon0

+ 3 other calls in file

44
45
46
47
48
49
50
51
52
53
     *     // **NOTE**: The dollar sign has to be escaped when using this as an ENV variable
     *     key: Binary;
     *   }
     * }
     */
    expect(() => BSON.EJSON.parse(process.env.CSFLE_KMS_PROVIDERS)).to.not.throw(SyntaxError);
  } else {
    this.skip();
  }
});
fork icon0
star icon0
watch icon0

+ 3 other calls in file

12
13
14
15
16
17
18
19
20
21
22
const { getEncryptExtraOptions } = require('../../tools/utils');
const { installNodeDNSWorkaroundHooks } = require('../../tools/runner/hooks/configuration');
const { coerce, gte } = require('semver');


const getKmsProviders = (localKey, kmipEndpoint, azureEndpoint, gcpEndpoint) => {
  const result = BSON.EJSON.parse(process.env.CSFLE_KMS_PROVIDERS || '{}');
  if (localKey) {
    result.local = { key: localKey };
  }
  result.kmip = {
fork icon0
star icon0
watch icon0

+ 3 other calls in file

169
170
171
172
173
174
175
176
177
178
handler: async (req, params) => {
  const body = await readBody(req);
  const request = JSON.parse(body.toString());
  let { uri, query, options } = request;
  if (query) {
    query = bson.EJSON.parse(JSON.stringify(query));
  }
  const client = await createMongoClient(uri);
  try {
    const rUri = new URL.URL(uri);
fork icon0
star icon0
watch icon0

+ 5 other calls in file