I have 2 files below
transaction.js
class Transaction {
constructor (txn) {
this.txn = txn;
}
startTransaction () {
this.conn.send(this.txn);
}
}
index.js
const Transaction = require('./transaction')
class Index {
constructor(option = {}) {
this.conn = this.setConnection(option.url); // { url: '', send: [Function] }
this.txn = Transaction;
}
}
let index = new Index({url: ''})
I need to have index.conn object to be assigned under new index.transaction(), when newly instantiated. So that, code below would work
let transaction = new index.txn({ data: 'here' });
transaction.startTransaction();
Any possible way in your mind?