Skip to main content

createTarget

Create a data sink.
createTarget(config: TargetConfig): Target
Parameters:
  • write: Write function async ({ctx, read}) => void (required)
  • fork: Fork handler async (previousBlocks: BlockCursor[]) => BlockCursor | null (optional)
Example:
const target = createTarget({
  write: async ({ logger, read }) => {
    for await (const { data } of read()) {
      await database.save(data);
    }
  },
});