code: function(instances) {
      var queryKey = this.foreignKey;
      var pks = _.map(instances, this.primaryKey);
  
      if (instances.length === 1) { pks = pks[0]; }
      else { queryKey += '$in'; }
  
      var where = _.object([[queryKey, pks]]);
      return this._relatedModel.objects.where(where);
    }
docs: Generate the prefetch query.
  
  Subclasses can override this.
  
  @method
  @protected
  @see {@link HasMany#_prefetch}