import { Injectable } from '@nestjs/common';
import { Changes } from 'src/couchdb-datasources/changes';
import nano from 'nano';
import { Change } from 'src/models/change.model';

@Injectable()
export class ChangesService {
  constructor(private changes: Changes) {}

  async find(query: nano.MangoQuery): Promise<Change[]> {
    const changesDb = await this.changes.getDatasource();
    const res = await changesDb.find(query);
    return res.docs;
  }
}
