const esClient = require('./client/streamClient').StreamClient;

class writeModel {

    constructor() {
        this.esClient = new esClient();
    }

    async appendToStream(streamName, eventType, eventData) {
        try {
            const currentEvent = this.esClient.createEvent(eventType, eventData);
            return await this.esClient.appendToStream(streamName, currentEvent); 
        } catch(error) {
            throw error;
        }
    }
}

exports.writeModel = writeModel;