Skip to content

Commit

Permalink
added a damas-core 2.5 retro compatibility switch
Browse files Browse the repository at this point in the history
  • Loading branch information
remyla committed Sep 25, 2024
1 parent b903ebe commit cb34911
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
6 changes: 2 additions & 4 deletions docker/compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
services:
damas:
container_name: damas-core
image: primcode/damas-core:experimental
image: primcode/damas-core:latest
volumes:
- ./damas.json:/damas-core/server-nodejs/conf.json
- ./www:/app/www
- ./extensions:/app/extensions
environment:
DEBUG: "damas:*"
HTTP_PORT: 8090
# ports:
# - 80:80
depends_on:
- mongo
restart: always
Expand All @@ -23,7 +21,7 @@ services:
container_name: damas-mongo
image: mongo:latest
volumes:
- ./db:/damas-core/db
- ./db:/data/db
restart: always
stdin_open: true
tty: true
Expand Down
3 changes: 2 additions & 1 deletion server-nodejs/conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"db": "node",
"collection": "node",
"port": 27017,
"options": { }
"options": { },
"create_returns_obj": true
},
"mongodb": {
"host": "mongo",
Expand Down
21 changes: 19 additions & 2 deletions server-nodejs/db/mongodb6.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

// SPECIFICATION BREAKING CHANGES (to add in documentation) :
// - create() method now returns identifier(s) and not entire object(s)
// - added a damas-core 2.5 retro compatibility switch `conf.create_returns_obj`

var async = require('async');

Expand Down Expand Up @@ -85,8 +86,24 @@ module.exports = function (conf) {
);
}
async.mapLimit(nodes, 100, createNode, function (err, array) {
fireEvent('create', array);
callback(false, array);
// damas-core 2.5 retro compatibility switch
if (self.conf.create_returns_obj === true) {
console.log("### damas-core retro compatibility switch ###");
console.log(array);
if (array.includes(null)) {
fireEvent('create', [null]);
callback(false, [null]);
return;
}
self.read(array, (err, res) => {
fireEvent('create', res);
callback(false, res);
});
}
else {
fireEvent('create', array);
callback(false, array);
}
});
});
}; // create()
Expand Down

0 comments on commit cb34911

Please sign in to comment.