text: 'use strict';
  const DataLoader = require('dataloader');
  class UserConnector {
    constructor(ctx) {
      this.ctx = ctx;
      this.loader = new DataLoader(this.fetch.bind(this));
    }
    fetch(ids) {
      const users = this.ctx.app.model.User.findAll({
        where: {
          id: {
            $in: ids,
          },
        },
      }).then(us => us.map(u => u.toJSON()));
      return users;
    }
    fetchByIds(ids) {
      return this.loader.loadMany(ids);
    }
    fetchById(id) {
      return this.loader.load(id);
    }
    fetchAll(){
      const users = this.ctx.app.model.User.findAll({
        attributes: ['username'],
        limit: 10,
      }).then(us => us.map(u => u.toJSON()));
      return users;
    }
  }
  module.exports = UserConnector; 