Skip to content

Commit

Permalink
fix #286 ulid error when null _id
Browse files Browse the repository at this point in the history
  • Loading branch information
remyla committed Aug 16, 2024
1 parent 7eb6083 commit bc18991
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions server-nodejs/extensions/ulid.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ module.exports = function (app) {
const pattern = new RegExp(app.locals.conf.ulid.replacedPattern || '{#}');
events.attach('pre-create', function (nodes) {
for(var i=0; i<nodes.length; i++){
if(undefined !== nodes[i]._id){
if(typeof nodes[i]._id === 'string'){
nodes[i]._id = nodes[i]._id.replace(pattern, ULID.ulid());
}
console.log(nodes[i]);
}
this.next();
});
Expand Down

0 comments on commit bc18991

Please sign in to comment.