constructor()

in cdk/lib/datastore.ts [18:67]


	constructor(scope: GuStack, id: string) {
		super(scope, id);

		const maybePreview = scope.stack.endsWith('-preview') ? '-preview' : '';

		const table = new Table(this, 'RecipeTable', {
			tableName: `recipes-backend${maybePreview}-indexstore-${scope.stage}`,
			billingMode: BillingMode.PAY_PER_REQUEST,
			partitionKey: {
				name: 'capiArticleId',
				type: AttributeType.STRING,
			},
			sortKey: {
				name: 'recipeUID',
				type: AttributeType.STRING,
			},
			pointInTimeRecovery: true,
			encryption: TableEncryption.AWS_MANAGED,
		});

		Tags.of(table).add('devx-backup-enabled', 'true');

		this.lastUpdatedIndexName = 'idxArticleLastUpdated';

		table.addGlobalSecondaryIndex({
			partitionKey: {
				name: 'capiArticleId',
				type: AttributeType.STRING,
			},
			sortKey: {
				name: 'lastUpdated',
				type: AttributeType.STRING,
			},
			projectionType: ProjectionType.ALL,
			indexName: this.lastUpdatedIndexName,
		});

		this.recipeUIDIndexName = 'idxRecipeUID';

		table.addGlobalSecondaryIndex({
			partitionKey: {
				name: 'recipeUID',
				type: AttributeType.STRING,
			},
			projectionType: ProjectionType.INCLUDE,
			indexName: this.recipeUIDIndexName,
			nonKeyAttributes: ['recipeVersion'],
		});
		this.table = table;
	}