Skip to content

Commit

Permalink
fix: index issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mbystedt committed Dec 19, 2024
1 parent a01e310 commit e09bcff
Show file tree
Hide file tree
Showing 12 changed files with 443 additions and 432 deletions.
524 changes: 262 additions & 262 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@aws-sdk/client-kinesis": "^3.709.0",
"@aws-sdk/client-kinesis": "^3.716.0",
"@mikro-orm/core": "^6.4.1",
"@mikro-orm/mongodb": "^6.4.1",
"@mikro-orm/nestjs": "^6.0.2",
Expand Down Expand Up @@ -64,7 +64,7 @@
"uuid": "^11.0.3"
},
"devDependencies": {
"@eslint/js": "^9.16.0",
"@eslint/js": "^9.17.0",
"@golevelup/ts-jest": "^0.6.1",
"@nestjs/cli": "^10.4.9",
"@nestjs/schematics": "^10.2.3",
Expand All @@ -85,9 +85,9 @@
"@types/passport-jwt": "^4.0.1",
"@types/supertest": "^6.0.2",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^8.18.0",
"@typescript-eslint/parser": "^8.18.0",
"eslint": "^9.16.0",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"jest": "^29.7.0",
Expand All @@ -99,7 +99,7 @@
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.6.3",
"typescript-eslint": "^8.18.0"
"typescript-eslint": "^8.18.1"
},
"jest": {
"moduleFileExtensions": [
Expand Down
5 changes: 3 additions & 2 deletions src/intention/entity/intention.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
SerializedPrimaryKey,
Index,
Embedded,
BaseEntity,
} from '@mikro-orm/core';
import { ObjectId } from 'mongodb';

Expand All @@ -26,8 +27,7 @@ import { UrlEmbeddable } from './url.embeddable';
import { BrokerAccountEntity } from '../../persistence/entity/broker-account.entity';

@Entity({ tableName: 'intention' })
// @Index(['actions.transaction.hash'])
export class IntentionEntity {
export class IntentionEntity extends BaseEntity {
constructor(
actions: (
| BackupActionEmbeddable
Expand All @@ -47,6 +47,7 @@ export class IntentionEntity {
expiry: number,
account: BrokerAccountEntity,
) {
super();
this.actions = actions;
this.event = event;
this.jwt = jwt;
Expand Down
3 changes: 1 addition & 2 deletions src/intention/entity/package.embeddable.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ObjectId } from 'mongodb';
import { ApiProperty } from '@nestjs/swagger';
import { Embeddable, Entity, Property } from '@mikro-orm/core';
import { Embeddable, Property } from '@mikro-orm/core';
import { PackageDto } from '../dto/package.dto';

@Entity()
@Embeddable()
export class PackageEmbeddable {
static merge(...theArgs: Array<PackageDto | PackageEmbeddable>) {
Expand Down
5 changes: 4 additions & 1 deletion src/persistence/entity/edge.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ApiHideProperty, ApiProperty } from '@nestjs/swagger';
import {
BaseEntity,
Embedded,
Entity,
Index,
Expand All @@ -13,7 +14,9 @@ import { TimestampEmbeddable } from './timestamp.embeddable';
import { EdgePropEmbeddable } from './edge-prop.embeddable';

@Entity({ tableName: 'edge' })
export class EdgeEntity {
@Index({ options: { 'timestamps.createdAt': 1 } })
@Index({ options: { 'timestamps.updatedAt': 1 } })
export class EdgeEntity extends BaseEntity {
@ApiHideProperty()
@PrimaryKey()
@Property()
Expand Down
9 changes: 7 additions & 2 deletions src/persistence/entity/jwt.entity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { PrimaryKey, Property, SerializedPrimaryKey } from '@mikro-orm/core';
import {
BaseEntity,
PrimaryKey,
Property,
SerializedPrimaryKey,
} from '@mikro-orm/core';
import { ObjectId } from 'mongodb';

export abstract class JwtEntity {
export abstract class JwtEntity extends BaseEntity {
@PrimaryKey()
@Property()
_id: ObjectId;
Expand Down
2 changes: 2 additions & 0 deletions src/persistence/entity/package-build.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export class PackageBuildApprovalEntity {
}

@Entity({ tableName: 'packageBuild' })
@Index({ options: { 'timestamps.createdAt': 1 } })
@Index({ options: { 'timestamps.updatedAt': 1 } })
export class PackageBuildEntity {
@PrimaryKey()
@Property()
Expand Down
4 changes: 1 addition & 3 deletions src/persistence/entity/timestamp.embeddable.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Embeddable, Index, Property } from '@mikro-orm/core';
import { Embeddable, Property } from '@mikro-orm/core';

@Embeddable()
export class TimestampEmbeddable {
@Index()
@Property()
createdAt: Date;

@Index()
@Property({ nullable: true })
updatedAt?: Date;

Expand Down
4 changes: 2 additions & 2 deletions src/persistence/entity/vertex-pointer.entity.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Property, Index } from '@mikro-orm/core';
import { Property, Index, BaseEntity } from '@mikro-orm/core';
import { ObjectId } from 'mongodb';
import { ApiProperty } from '@nestjs/swagger';

export abstract class VertexPointerEntity {
export abstract class VertexPointerEntity extends BaseEntity {
@Property()
@ApiProperty({ type: () => String })
@Index()
Expand Down
5 changes: 4 additions & 1 deletion src/persistence/entity/vertex.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
SerializedPrimaryKey,
Index,
Embedded,
BaseEntity,
} from '@mikro-orm/core';
import { ObjectId } from 'mongodb';
import { ApiHideProperty, ApiProperty } from '@nestjs/swagger';
Expand All @@ -16,7 +17,9 @@ import { TimestampEmbeddable } from './timestamp.embeddable';
import { CollectionEntityUnion } from './collection-entity-union.type';

@Entity({ tableName: 'vertex' })
export class VertexEntity {
@Index({ options: { 'timestamps.createdAt': 1 } })
@Index({ options: { 'timestamps.updatedAt': 1 } })
export class VertexEntity extends BaseEntity {
@ApiHideProperty()
@PrimaryKey()
@Property()
Expand Down
Loading

0 comments on commit e09bcff

Please sign in to comment.