handleShutdown() { if (!this._client) { return Promise.resolve(); } return this._client.close(false); }
disconnect() { if (this.client) { this.client.close(); } }
createTransactionalSession() { const transactionalSection = this.client.startSession(); transactionalSection.startTransaction(); return Promise.resolve(transactionalSection); }
it("doesn't double escape already URI-encoded information", () => { spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(fakeClient)); new MongoStorageAdapter({ uri: 'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse', }).connect(); expect(MongoClient.connect).toHaveBeenCalledWith( 'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse', jasmine.any(Object) ); });
app.post('/collect', (req, res) => { console.log(req.body); const client = new MongoClient(process.env.MONGO_URL); client.connect((err) => { const db = client.db(); const collection = db.collection('events'); collection.insertOne({ timestamp: new Date(), ...req.body }, ((err, result) => { client.close(); res.send('ok'); })); }); });
handleShutdown() { if (!this.client) { return Promise.resolve(); } return this.client.close(false); }
// https://github.com/parse-community/parse-server/pull/148#issuecomment-180407057 it('preserves replica sets', () => { spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(fakeClient)); new MongoStorageAdapter({ uri: 'mongodb://test:testpass@ds056315-a0.mongolab.com:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415', }).connect(); expect(MongoClient.connect).toHaveBeenCalledWith( 'mongodb://test:testpass@ds056315-a0.mongolab.com:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415', jasmine.any(Object) ); });
handleShutdown() { if (!this._client) { return Promise.resolve(); } return this._client.close(false); }
handleShutdown() { if (!this._client) { return Promise.resolve(); } return this._client.close(false); }