_toMongoDocument (it) {
      if (typeof it === 'function') {
        throw new IllegalArgumentError({
          message: 'functions cannot be converted to a mongo document'
        })
      }
      if (Array.isArray(it)) return it.map(it => this._toMongoDocument(it))
      if (Enumeration.isInstance(it)) return it.name

      if (typeof it === 'object') {
        if (it === null) return it

        return Object.keys(it)
          .filter(k => typeof it[k] !== 'function' && it[k] !== undefined)
          .map(k => ({ [k]: this._toMongoDocument(it[k]) }))
          .reduce((accum, next) => Object.assign(accum, next), {})
      }

      return it
    }
/**
     * Converts the given entity into a plain, JavaScript object suitable for persistence into MongoDB.
     *
     * @param it
     * @return {*}
     */
Converts the given entity into a plain, JavaScript object suitable for persistence into MongoDB.
@param it
@return {*}
Converts the given entity into a plain JavaScript object suitable for persistence into MongoDB . @param it @return { * }
_toMongoDocument (it) {
      if (typeof it === 'function') {
        throw new IllegalArgumentError({
          message: 'functions cannot be converted to a mongo document'
        })
      }
      if (Array.isArray(it)) return it.map(it => this._toMongoDocument(it))
      if (Enumeration.isInstance(it)) return it.name
      if (typeof it === 'object') {
        if (it === null) return it
        return Object.keys(it)
          .filter(k => typeof it[k] !== 'function' && it[k] !== undefined)
          .map(k => ({ [k]: this._toMongoDocument(it[k]) }))
          .reduce((accum, next) => Object.assign(accum, next), {})
      }
      return it
    }
_toMongoDocument ( it ) { if ( typeof it === 'function' ) { throw new IllegalArgumentError ( { message : 'functions cannot be converted to a mongo document' } ) } if ( Array . isArray ( it ) ) return it . map ( it => this . _toMongoDocument ( it ) ) if ( Enumeration . isInstance ( it ) ) return it . name if ( typeof it === 'object' ) { if ( it === null ) return it return Object . keys ( it ) . filter ( k => typeof it [ k ] !== 'function' && it [ k ] !== undefined ) . map ( k => ( { [ k ] : this . _toMongoDocument ( it [ k ] ) } ) ) . reduce ( ( accum , next ) => Object . assign ( accum , next ) , { } ) } return it }
Converts the given entity into a plain, JavaScript object suitable for persistence into MongoDB.
Converts the given entity into a plain JavaScript object suitable for persistence into MongoDB .