Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeORM: AggregateColumn Decorator #8

Merged
merged 11 commits into from
Jan 30, 2025
Merged

TypeORM: AggregateColumn Decorator #8

merged 11 commits into from
Jan 30, 2025

Conversation

danstarns
Copy link
Collaborator

@danstarns danstarns commented Jan 29, 2025

This PR adds the @AggregateColumn and @BucketColumn decorators to the TypeORM integration. This removes the need for a large object when specifying the cagg.

Usage:

import { ViewColumn } from 'typeorm';
import { ContinuousAggregate, AggregateColumn, BucketColumn } from '@timescaledb/typeorm';
import { PageLoad } from './PageLoad';

@ContinuousAggregate(PageLoad, {
  name: 'hourly_page_views',
  bucket_interval: '1 hour',
  refresh_policy: {
    start_offset: '3 days',
    end_offset: '1 hour',
    schedule_interval: '1 hour',
  },
})
export class HourlyPageViews {
  @BucketColumn({
    source_column: 'time',
  })
  bucket!: Date;

  @AggregateColumn({
    type: 'count',
  })
  total_views!: number;

  @AggregateColumn({
    type: 'unique_count',
    column: 'user_agent',
  })
  unique_users!: number;
}

@danstarns danstarns changed the title Aggregate Directive AggregateColumn Jan 30, 2025
@danstarns danstarns changed the title AggregateColumn TypeORM: AggregateColumn Decorator Jan 30, 2025
@danstarns danstarns merged commit cc47fbb into main Jan 30, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant