Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should fire events when we communicate with a collection, and preserve context", function(done) {
channel.addContextPreservation((cb) => Zone.current.wrap(cb, "context preservation"));
const events: Array> = [];
channel.subscribe("mongodb", function(event) {
events.push(event);
});
const mongodb = require("mongodb");
const z1 = Zone.current.fork({name: "1"});
z1.run(() =>
mongodb.MongoClient.connect("mongodb://localhost:27017", { useNewUrlParser: true }, function(err, client) {
if (err) {
done(err);
}
const collection = client.db("testdb").collection("documents");
before(() => {
enablePostgres();
enablePostgresPool();
channel.addContextPreservation((cb) => Zone.current.wrap(cb, "context preservation"));
pg = require("pg");
pool = new pg.Pool({
user: dbSettings.user,
password: dbSettings.password,
database: dbSettings.database,
host: dbSettings.host,
port: dbSettings.port,
max: 2,
});
});