param from param fallback export function extractSingleMongoId < T = undefined > ( from , fallback ? ) { if ( typeof from === 'string' || from instanceof String ) { return from . toString ( ) ; } else if ( from instanceof Object ) { if ( from . _bsontype === 'ObjectID' ) { return from . toString ( ) ; } else if ( 'id' in from ) { return from . id . toString ( ) ; } else if ( '_id' in from ) { return from . _id . toString ( ) ; } } return fallback ; } param from param fallback export function extractMongoId < T = undefined > ( from , fallback ? ) { if ( Array . isArray ( from ) ) { const results = [ ] ; for ( const value of from ) { const result = extractSingleMongoId ( value , fallback ) ; if ( result !== undefined ) { results . push ( result ) ; } } return results ; } else { return extractSingleMongoId ( from , fallback ) ; } }