Posts

Showing posts with the label pagination

Guide to Querying and Pagination with AWS DynamoDB in NestJS

Image
Introduction In my previous article, I provided a basic guide on initializing and using AWS DynamoDB, but in this article, we will delve deeper into QueryCommand. In AWS DynamoDB, the Query method allows you to search for data based on the primary key (Partition Key) and filter conditions (Sort Key). To optimize performance and cost, DynamoDB supports a Pagination mechanism through the ExclusiveStartKey and LastEvaluatedKey parameters. Applying pagination not only reduces the data transfer load but also enables the application to handle large data tables smoothly, ensuring system stability. Detail Use AWS CDK to create the file lib/dynamodb-gsi-stack.ts import * as cdk from "aws-cdk-lib" import * as dynamodb from "aws-cdk-lib/aws-dynamodb" import { Construct } from "constructs" export class DynamoDbGsiStack extends cdk . Stack { constructor ( scope : Construct , id : string , props ?: cdk . StackProps ) { super (scope, id, props) ...

Guide to using Pothos GraphQL

Image
Introduction Pothos GraphQL is a GraphQL Schema Builder , which is a library that helps you write/define a GraphQL Schema using TypeScript code (a Code-First API approach). Functions Helps define each Query , Mutation and GraphQL Type using strongly typed TypeScript code, automatically catching errors to ensure 100% Type Safety . Pothos has a built-in plugin to connect with Drizzle (@pothos/plugin-drizzle) . You only need to declare tables in Drizzle corresponding to Objects in GraphQL and Pothos will automatically understand relations, pagination , helping you avoid writing complex SELECT/JOIN statements. Detail bun add @pothos/core @pothos/plugin-drizzle @pothos/plugin-zod Create file src/drizzle-orm/schema/schema.ts import {sql} from 'drizzle-orm' import { check, decimal, integer, pgTable, serial, text, timestamp, unique, varchar, } from 'drizzle-orm/pg-core' export const baseColumns = { id : serial ( 'id' ). primaryKe...