index.js
/**
   * If id is provided, it tries to get the element with the given id.
   * It will throw an error if no element is found. If no id is provided
   * lists all the stored items.
   *
   * @async
   * @param  {String} id
   * @return {Promise} Resolved with the object or the array of objects or
   * rejected with an error.
   */
If id is provided, it tries to get the element with the given id.
It will throw an error if no element is found. If no id is provided
lists all the stored items.

@async
@param  {String} id
@return {Promise} Resolved with the object or the array of objects or
rejected with an error.
If id is provided it tries to get the element with the given id . It will throw an error if no element is found . If no id is provided lists all the stored items . @async @param { String } id @return { Promise } Resolved with the object or the array of objects or rejected with an error .
async list (id, json = true) {
    if (id) {
      try {
        const el = await this.model.find({ _id: id }).exec()
        if (!el || el.length === 0) throw new Error()
        if (json) return el.pop().toJSON()
        return el.pop()
      } catch (e) {
        const err = new Error('Resource not found')
        err.status = 404
        err.data = {}
        throw err
      }
    }
    return this.model.find({}).exec()
  }
async list ( id , json = true ) { if ( id ) { try { const el = await this . model . find ( { _id : id } ) . exec ( ) if ( ! el || el . length === 0 ) throw new Error ( ) if ( json ) return el . pop ( ) . toJSON ( ) return el . pop ( ) } catch ( e ) { const err = new Error ( 'Resource not found' ) err . status = 404 err . data = { } throw err } } return this . model . find ( { } ) . exec ( ) }
If id is provided, it tries to get the element with the given id.
If id is provided it tries to get the element with the given id .