Skip to content

Commit

Permalink
Merge pull request #393 from Freezystem/fix/remove-bluebird-from-knex…
Browse files Browse the repository at this point in the history
…-adapter

Remove bluebird from moleculer-db-adapter-knex
  • Loading branch information
icebob authored Sep 30, 2024
2 parents 1b3cbf6 + fb30cec commit ef97b43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
17 changes: 9 additions & 8 deletions proposal/moleculer-db-adapter-knex/examples/simple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ let { ServiceBroker } = require("moleculer");
let StoreService = require("../../../moleculer-db/index");
let ModuleChecker = require("../../../moleculer-db/test/checker");
let KnexAdapter = require("../../index");
let Promise = require("bluebird");

const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));

// Create broker
let broker = new ServiceBroker({
Expand Down Expand Up @@ -47,11 +48,11 @@ const checker = new ModuleChecker(24);
// Start checks
function start() {
return Promise.resolve()
.delay(500)
.then(() => delay(500))
.then(() => checker.execute())
.catch(console.error)
.then(() => broker.stop())
.then(() => checker.printTotal());
.then(() => checker.printTotal());
}

// --- TEST CASES ---
Expand Down Expand Up @@ -110,7 +111,7 @@ checker.add("INSERT MANY", () => adapter.insertMany([
checker.add("COUNT", () => adapter.count(), res => {
console.log(res);
return res == 3;
});
});

// Find
checker.add("FIND by query", () => adapter.find({ query: { title: "Last" } }), res => {
Expand Down Expand Up @@ -153,8 +154,8 @@ checker.add("GET BY IDS", () => adapter.findByIds([ids[2], ids[0]]), res => {
});

// Update a posts
checker.add("UPDATE", () => adapter.updateById(ids[2], { $set: {
title: "Last 2",
checker.add("UPDATE", () => adapter.updateById(ids[2], { $set: {
title: "Last 2",
updatedAt: new Date(),
status: true
}}), doc => {
Expand All @@ -163,7 +164,7 @@ checker.add("UPDATE", () => adapter.updateById(ids[2], { $set: {
});

// Update by query
checker.add("UPDATE BY QUERY", () => adapter.updateMany({ votes: { $lt: 5 }}, {
checker.add("UPDATE BY QUERY", () => adapter.updateMany({ votes: { $lt: 5 }}, {
$set: { status: false }
}), count => {
console.log("Updated: ", count);
Expand All @@ -180,7 +181,7 @@ checker.add("REMOVE BY QUERY", () => adapter.removeMany({ votes: { $lt: 5 }}), c
checker.add("COUNT", () => adapter.count(), res => {
console.log(res);
return res == 1;
});
});

// Remove by ID
checker.add("REMOVE BY ID", () => adapter.removeById(ids[1]), doc => {
Expand Down
1 change: 0 additions & 1 deletion proposal/moleculer-db-adapter-knex/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"use strict";

const _ = require("lodash");
const Promise = require("bluebird");
const Knex = require("knex");

class KnexDbAdapter {
Expand Down

0 comments on commit ef97b43

Please sign in to comment.