Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove bluebird from moleculer-db-adapter-knex #393

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading