Skip to content

Commit

Permalink
Serialize the id if its an ObjectID, fixes fortunejs#5
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Yartsev committed Sep 24, 2017
1 parent 7e8c626 commit b8565ec
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const crypto = require('crypto')
const ObjectID = require('mongodb').ObjectID

const idKey = '_id'

Expand Down Expand Up @@ -45,6 +46,9 @@ function outputRecord (type, record) {

// ID business.
clone[primaryKey] = record[idKey]
if(ObjectID.isValid(clone[primaryKey])) {
clone[primaryKey] = clone[primaryKey].toHexString()
}

// Non-native types.
for (const field of Object.getOwnPropertyNames(fields)) {
Expand Down

0 comments on commit b8565ec

Please sign in to comment.