1.3.1 • Published 1 year ago

pp_dictionary v1.3.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Dictionaries

Rename .env.example to .env, and edit clickhouse connection credentials

Add library to your project.

// Example usage:
// Init with params
const manager1 = new DictionaryManager({
  hostURL: 'http://localhost:8123',
  username: '',
  password: '',
});
// set how to deal with connection
const leaveConnection = false;
await manager1.loadAllTables(leaveConnection);

const chClient = createClient({
  host: 'http://localhost:8123',
  username: '',
  password: '',
  request_timeout: 30_000,
});
// OR init with existing ClickHouseClient;
const manager2 = new DictionaryManager({ clickHouseClient: chClient });

// close or not connection after loading table data
const closeConnection = true;
// Load only one table
await manager2.loadSingleTable(Dictionary.ExchangePools, closeConnection);

// Define Type of the same name in singular from table name ex: 'Dog' for 'Dogs', 'Cat' for 'Cats'
const exchanges = manager1.find<ExchangePool>(Dictionary.ExchangePools, {
  trading_pair_id: '1',
});
// Typehints will be enabled
const exchangesId = exchanges.map((exchange) => exchange.id);
console.log(exchangesId);

// Load whole table data with `getAll` method
const tokens = manager1.getAll<Token>(Dictionary.Tokens);
console.log(tokens.length);

Available Dictionaries

  • Exchange
  • ExchangePool
  • SamplingPeriod
  • Token
  • TradingPair
  • Unit
1.2.0

1 year ago

1.1.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.0.0

1 year ago