db.from('capcodes') .del() .where('id', 'in', idList) .then((result) => { res.status(200).send({ 'status': 'ok' }); if (!updateRequired || updateRequired == 0) { nconf.set('database:aliasRefreshRequired', 1); nconf.save(); } }).catch((err) => { res.status(500).send(err); })
describe('Initializing', function () { it('Should create a database table for caching if it does not exist or empty existing one', async () => { if (await knex.schema.hasTable('cache')) { await knex.table('cache').del() } else { await knex.schema.createTable('cache', function (table) { table.string('key').unique() table.text('value') table.integer('expiration') }) } }) })
//delete cat by ID function deleteOne(id) { return db("cats") .where({ id }) .del() .then(data => { // the data callback here doesn't return any cats as we've deleted the cat. So returning whole DB. return db("cats").select(); }); }
describe('Valid request (Test ID 12345678901234567890)', function () { this.slow(15 * 1000); this.timeout(20 * 1000); const test = () => ratelimitBypass(request().get('/api/bots/12345678901234567890')); it('does not have cached data for the first request', done => { db('cache').where({ route: '/api/bots/12345678901234567890' }).del().then(() => { test().end((err, res) => { expect(res.body).to.have.property('id', '12345678901234567890'); expect(res.body).to.have.property('cached', false); done(); }); }); }); it('uses cached data for any subsequent request', done => { test().end((err, res) => { expect(res.body).to.have.property('id', '12345678901234567890'); expect(res.body).to.have.property('cached', true); expect(res.body).to.have.property('cache_expires_at'); expect(res.body).to.have.property('cache_expires_in'); done(); }); }); });
db.from('users') .del() .where('id', id) .then((result) => { res.status(200).send({ 'status': 'ok' }); }) .catch((err) => { res.status(500).send(err); logger.main.error(err) })
.del() .where('id', 'in', idList) .then((result) => {
const db = database; const contactToDelete = await db("contacts") .del() .where({ id });
db.from('capcodes') .del() .where('id', id) .then((result) => { res.status(200).send({ 'status': 'ok' }); if (!updateRequired || updateRequired == 0) { nconf.set('database:aliasRefreshRequired', 1); nconf.save(); } }) .catch((err) => { res.status(500).send(err); })