function deepCopy(obj, strictKeys) {
  if (
    typeof obj === 'boolean' ||
    typeof obj === 'number' ||
    typeof obj === 'string' ||
    obj === null ||
    (isDate(obj))
  ) return obj

  if (Array.isArray(obj)) return obj.map(o => deepCopy(o, strictKeys))

  if (typeof obj === 'object') {
    const res = {}
    for (const k in obj) {
      if (
        Object.prototype.hasOwnProperty.call(obj, k) &&
        (!strictKeys || (k[0] !== '$' && k.indexOf('.') === -1))
      ) {
        res[k] = deepCopy(obj[k], strictKeys)
      }
    }
    return res
  }

  return undefined // For now everything else is undefined. We should probably throw an error instead
}
/**
 * Deep copy a DB object
 * The optional strictKeys flag (defaulting to false) indicates whether to copy everything or only fields
 * where the keys are valid, i.e. don't begin with $ and don't contain a .
 */
Deep copy a DB object
The optional strictKeys flag (defaulting to false) indicates whether to copy everything or only fields
where the keys are valid, i.e. don't begin with $ and don't contain a .
Deep copy a DB object The optional strictKeys flag ( defaulting to false ) indicates whether to copy everything or only fields where the keys are valid i . e . don ' t begin with $ and don ' t contain a .
function deepCopy(obj, strictKeys) {
  if (
    typeof obj === 'boolean' ||
    typeof obj === 'number' ||
    typeof obj === 'string' ||
    obj === null ||
    (isDate(obj))
  ) return obj
  if (Array.isArray(obj)) return obj.map(o => deepCopy(o, strictKeys))
  if (typeof obj === 'object') {
    const res = {}
    for (const k in obj) {
      if (
        Object.prototype.hasOwnProperty.call(obj, k) &&
        (!strictKeys || (k[0] !== '$' && k.indexOf('.') === -1))
      ) {
        res[k] = deepCopy(obj[k], strictKeys)
      }
    }
    return res
  }
  return undefined 
}
function deepCopy ( obj , strictKeys ) { if ( typeof obj === 'boolean' || typeof obj === 'number' || typeof obj === 'string' || obj === null || ( isDate ( obj ) ) ) return obj if ( Array . isArray ( obj ) ) return obj . map ( o => deepCopy ( o , strictKeys ) ) if ( typeof obj === 'object' ) { const res = { } for ( const k in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , k ) && ( ! strictKeys || ( k [ 0 ] !== '$' && k . indexOf ( '.' ) === - 1 ) ) ) { res [ k ] = deepCopy ( obj [ k ] , strictKeys ) } } return res } return undefined }
Deep copy a DB object
 The optional strictKeys flag (defaulting to false) indicates whether to copy everything or only fields
 where the keys are valid, i.e.
Deep copy a DB object The optional strictKeys flag ( defaulting to false ) indicates whether to copy everything or only fields where the keys are valid i . e .
// For now everything else is undefined. We should probably throw an error instead