// tslint:disable:no-console
import * as mongoose from 'mongoose';

import { chevre } from '../../../lib/index';

const PROJECT_ID = String(process.env.PROJECT_ID);

async function main() {
    await mongoose.connect(<string>process.env.MONGOLAB_URI);

    const productOfferRepo = await chevre.repository.ProductOffer.createInstance(mongoose.connection);

    const offers = await productOfferRepo.search({
        project: { id: { $eq: PROJECT_ID } }
        // seller: { id: { $eq: 'xxx' } }
    });
    console.log(offers);
    console.log(offers.length);

    // await productOfferRepo.deleteOne({
    //     project: { id: PROJECT_ID },
    //     seller: { id: 'xxx' },
    //     itemOffered: { id: 'xxx' }
    // });
}

main()
    .then(console.log)
    .catch(console.error);
