### Clone Nile Example Repository (Shell) Source: https://www.thenile.dev/docs/getting-started/languages/python Clones the Nile database example repository from GitHub and navigates into the Python quickstart directory. This is the first step to setting up the project locally. ```Shell git clone https://github.com/niledatabase/niledatabase cd niledatabase/examples/quickstart/python ``` -------------------------------- ### Clone Nile Database Example Repository Source: https://www.thenile.dev/docs/getting-started/languages/drizzle Clones the Nile database quickstart repository from GitHub and navigates into the Drizzle ORM example directory. This sets up the project structure for the tutorial. ```bash git clone https://github.com/niledatabase/niledatabase cd niledatabase/examples/quickstart/drizzle ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/getting-started/getting-started This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Nile CLI Authentication Quickstart Source: https://www.thenile.dev/docs/cli/using_auth Initiates a quickstart process for adding multi-tenant authentication to a Next.js application. This command automates the setup of database credentials, Nile package installation, API route configuration, authentication components, and starts the development server. ```bash nile auth quickstart --nextjs ``` -------------------------------- ### Clone Nile Repository and Navigate Source: https://www.thenile.dev/docs/getting-started/examples/task_genius Clones the Nile database repository from GitHub and changes the directory to the Python quickstart examples. This is the initial step to get the project code. ```Shell git clone https://github.com/niledatabase/niledatabase cd niledatabase/examples/quickstart/python ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/docs/getting-started This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Install Node.js Dependencies Source: https://www.thenile.dev/docs/getting-started/languages/drizzle Installs the necessary Node.js project dependencies using npm. This command should be run after cloning the repository and setting up the environment variables. ```bash npm install ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/docs/tenant-virtualization/tenant-management This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/auth/quickstart This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/docs/getting-started This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Install Python Dependencies Source: https://www.thenile.dev/docs/getting-started/languages/python Installs all necessary Python packages listed in the requirements.txt file. Ensure you have activated your virtual environment before running this command. ```Shell pip install -r requirements.txt ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/getting-started/getting-started This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Nile CLI Quick Start Source: https://www.thenile.dev/docs/cli/introduction Verifies the Nile CLI installation, logs into the Nile service, and lists available databases. These commands are essential for initial setup and verification. ```bash # Verify installation nile --version # Login to Nile nile connect login # List your databases nile db list ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/docs/tenant-virtualization/tenant-isolation This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/getting-started/getting-started This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/docs/reference/sdk-reference This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/getting-started/schema_migrations/sqlalchemy This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/docs/getting-started This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/getting-started/schema_migrations/sqlalchemy This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/auth/api-reference/auth/sign-in-to-the-application This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/auth/quickstart This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Python Environment Setup Source: https://www.thenile.dev/docs/getting-started/languages/python Sets up a Python virtual environment and activates it. This is a recommended first step for managing project dependencies. ```Shell python -m venv venv source venv/bin/activate ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/auth/quickstart This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Clone Nile Quickstart Repository Source: https://www.thenile.dev/docs/getting-started/languages/node This command clones the Nile quickstart repository from GitHub, which contains example code for building an AI-native application. It then navigates into the Node.js and React example directory. ```bash git clone https://github.com/niledatabase/niledatabase cd niledatabase/examples/quickstart/node_react ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/ai-embeddings/pg_vector This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/getting-started/schema_migrations/sqlalchemy This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/ai-embeddings/embeddin-models/google This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/docs/tenant-virtualization/tenant-management This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Manage Tenants and Todos via API Source: https://www.thenile.dev/docs/getting-started/languages/drizzle Provides `curl` commands to interact with the backend API for managing tenants and todos. It includes examples for creating a tenant, listing tenants, creating a todo for a specific tenant, and listing todos for a tenant. ```bash # create a tenant curl --location --request POST 'localhost:3001/api/tenants' \ --header 'Content-Type: application/json' \ --data-raw '{"name":"my first customer", "id":"108124a5-2e34-418a-9735-b93082e9fbf2"}' # get tenants curl -X GET 'http://localhost:3001/api/tenants' # create a todo (don't forget to use a read tenant-id in the URL) curl -X POST \ 'http://localhost:3001/api/tenants/108124a5-2e34-418a-9735-b93082e9fbf2/todos' \ --header 'Content-Type: application/json' \ --data-raw '{"title": "feed the cat", "complete": false}' # list todos for tenant (don't forget to use a read tenant-id in the URL) curl -X GET \ 'http://localhost:3001/api/tenants/108124a5-2e34-418a-9735-b93082e9fbf2/todos' ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/open_ai This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/cohere This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Build UI Assets and Run Application Source: https://www.thenile.dev/docs/getting-started/examples/task_genius Navigates to the UI directory, installs Node.js dependencies using npm, builds the UI assets, and then starts the Python web application using uvicorn. The application will be accessible at http://localhost:8000. ```Shell cd ui npm install npm run build # Then start the Python webapp: uvicorn main:app --reload ``` -------------------------------- ### Get Started with SQL Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/fireworks This section provides guidance on getting started with SQL in the context of Nile. It assumes familiarity with standard SQL practices. ```sql -- Example SQL for Nile -- CREATE TABLE tenants ( -- id SERIAL PRIMARY KEY, -- name VARCHAR(255) NOT NULL -- ); ``` -------------------------------- ### Install Nile Auth Packages Source: https://www.thenile.dev/docs/auth/getting-started/installation Installs the server and client packages for Nile Auth using npm, yarn, or pnpm. These packages are essential for integrating Nile Auth into your application. ```bash npm install @niledatabase/server @niledatabase/client ``` -------------------------------- ### Clone Example Project and Install Dependencies Source: https://www.thenile.dev/docs/getting-started/schema_migrations/drizzle Clones the Drizzle migration example project from GitHub and installs necessary npm dependencies, including drizzle-kit, drizzle-orm, dotenv, and pg-node. ```bash git clone https://github.com/niledatabase/niledatabase.git cd examples/migrations/drizzle npm i ``` -------------------------------- ### Get Started with Node.js Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/deepinfra This section details how to get started with Nile using Node.js. It includes setup and basic interaction with the Nile API. ```javascript const { Nile } = require('@nile/sdk'); const nile = new Nile({ // Nile connection details }); async function main() { const users = await nile.users.list(); console.log(users); } ``` -------------------------------- ### Set Up Next.js Project with Nile AI PDF Example Source: https://www.thenile.dev/docs/getting-started/examples/chat_with_pdf Commands to clone the Nile AI PDF example project using `create-next-app` and set up the environment. This includes installing dependencies and configuring environment variables with workspace, database credentials, and third-party API keys. ```bash npx create-next-app -e https://github.com/niledatabase/niledatabase/tree/main/examples/ai/ai_pdf nile-ai-pdf cd nile-ai-pdf npx create-next-app -e https://github.com/niledatabase/niledatabase/tree/main/examples/ai/ai_pdf nile-ai-pdf cd nile-ai-pdf # Rename .env.example to .env.local and update with your details # Install dependencies yarn install # or npm install ``` -------------------------------- ### Get Started with Node.js Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/voyage This section details how to get started with Nile using Node.js. It includes setup and basic interaction with the Nile API. ```javascript const { Nile } = require('@nile/sdk'); const nile = new Nile({ // Nile connection details }); async function main() { const users = await nile.users.list(); console.log(users); } ``` -------------------------------- ### Install Python Dependencies Source: https://www.thenile.dev/docs/getting-started/examples/task_genius Installs all the necessary Python packages listed in the 'requirements.txt' file using pip. This ensures the project has all its required libraries to run. ```Shell pip install -r requirements.txt ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/docs/tenant-virtualization/tenant-management This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Get Started with Node.js Source: https://www.thenile.dev/docs/getting-started/getting-started This section covers setting up Node.js applications to work with Nile, likely using a PostgreSQL client library. ```javascript // Example Node.js connection using 'pg' // const { Pool } = require('pg'); // // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // pool.query('SELECT NOW()', (err, res) => { // if (err) { // console.error(err); // } else { // console.log(res.rows[0]); // } // pool.end(); // }); ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/docs/tenant-virtualization/tenant-isolation This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### API Examples for Tenant and Todo Management Source: https://www.thenile.dev/docs/getting-started/languages/prisma Provides examples using `curl` to interact with the application's API for managing tenants and todos. It demonstrates creating a tenant, listing tenants, creating a todo item for a specific tenant, and listing todos for a tenant. ```Shell # create a tenant curl --location --request POST 'localhost:3001/api/tenants' \ --header 'Content-Type: application/json' \ --data-raw '{"name":"my first customer", "id":"108124a5-2e34-418a-9735-b93082e9fbf2"}' # get tenants curl -X GET 'http://localhost:3001/api/tenants' # create a todo (don't forget to use a read tenant-id in the URL) curl -X POST \ 'http://localhost:3001/api/tenants/108124a5-2e34-418a-9735-b93082e9fbf2/todos' \ --header 'Content-Type: application/json' \ --data-raw '{"title": "feed the cat", "complete": false}' # list todos for tenant (don't forget to use a read tenant-id in the URL) curl -X GET \ 'http://localhost:3001/api/tenants/108124a5-2e34-418a-9735-b93082e9fbf2/todos' ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/docs/reference/sdk-reference This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Install Prisma Client and Generate Source: https://www.thenile.dev/docs/getting-started/languages/prisma Installs the Prisma client package and generates the Prisma client. This makes the Prisma client available for use in the application to interact with the database. ```bash npm install @prisma/client npx prisma generate ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/auth/api-reference/auth/sign-in-to-the-application This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Get Started with Node.js Source: https://www.thenile.dev/docs/docs/getting-started This section covers setting up Node.js applications to work with Nile, likely using a PostgreSQL client library. ```javascript // Example Node.js connection using 'pg' // const { Pool } = require('pg'); // // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // pool.query('SELECT NOW()', (err, res) => { // if (err) { // console.error(err); // } else { // console.log(res.rows[0]); // } // pool.end(); // }); ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/ai-embeddings/embeddin-models/google This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/fireworks This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Clone Nile Repository and Navigate Source: https://www.thenile.dev/docs/getting-started/languages/prisma Clones the Nile database repository from GitHub and changes the directory to the Prisma quickstart example. This is a prerequisite for setting up the project environment. ```Shell git clone https://github.com/niledatabase/niledatabase cd niledatabase/examples/quickstart/prisma ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/ai-embeddings/pg_vector This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/open_ai This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Clone Project and Navigate Source: https://www.thenile.dev/docs/getting-started/examples/sales_insight Clones the Nile database repository and navigates into the sales insight example directory. ```bash git clone https://github.com/niledatabase/niledatabase.git cd niledatabase/examples/sales_insight ``` -------------------------------- ### Get Started with Prisma Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/cohere This section details how to use Prisma with Nile for database management. It includes schema definition and migration examples. ```prisma // Example Prisma schema for Nile // model User { // id Int @id @default(autoincrement()) // email String @unique // name String? // tenantId Int // } // // datasource db { // url = env("DATABASE_URL") // provider = "postgresql" // } ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/deepinfra This section guides users on integrating Nile with a NextJS application. It covers setting up the environment and basic connection. ```javascript import { Nile } from '@nile/sdk'; const nile = new Nile({ // Nile connection details }); async function main() { // Example usage const users = await nile.users.list(); console.log(users); } ``` -------------------------------- ### Get Started with Node.js Source: https://www.thenile.dev/docs/auth/quickstart This section covers setting up Node.js applications to work with Nile, likely using a PostgreSQL client library. ```javascript // Example Node.js connection using 'pg' // const { Pool } = require('pg'); // // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // pool.query('SELECT NOW()', (err, res) => { // if (err) { // console.error(err); // } else { // console.log(res.rows[0]); // } // pool.end(); // }); ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/voyage This section guides users on integrating Nile with a NextJS application. It covers setting up the environment and basic connection. ```javascript import { Nile } from '@nile/sdk'; const nile = new Nile({ // Nile connection details }); async function main() { // Example usage const users = await nile.users.list(); console.log(users); } ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/docs/tenant-virtualization/tenant-isolation This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Configure Environment Variables for Nile and AI Source: https://www.thenile.dev/docs/getting-started/languages/drizzle Sets up the `.env` file with database connection details from Nile and API credentials for AI services (OpenAI compatible). It includes placeholders for API key, base URL, and model names. ```bash DATABASE_URL=postgres://018b778a-30df-7cdd-b55c-2f9664db39f3:ff3fb983-683c-4616-bbbc-519d8ddbbce5@db.thenile.dev:5432/gwen_db # for AI estimates AI_API_KEY=your_api_key_for_openai_compatible_service AI_BASE_URL=https://api.fireworks.ai/inference/v1 AI_MODEL=accounts/fireworks/models/llama-v3p1-405b-instruct EMBEDDING_MODEL=nomic-ai/nomic-embed-text-v1.5 ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/docs/reference/sdk-reference This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Clone Nile Example and Set Up NextJS Environment Source: https://www.thenile.dev/docs/getting-started/languages/nextjs This Bash script clones the Nile database examples repository and navigates into the NextJS quickstart directory. It's the initial step for setting up a NextJS application that utilizes Nile's features. Users are instructed to rename the environment file and update it with their specific credentials. ```Bash git clone https://github.com/niledatabase/niledatabase cd niledatabase/examples/quickstart/nextjs ``` -------------------------------- ### Utilize Nile Auth Client APIs Source: https://www.thenile.dev/docs/auth/getting-started/installation Demonstrates how to import functions like getSession and signUp from the Nile Auth client package. These functions are used to manage user sessions and sign-up processes. ```typescript import { getSession, signUp } from '@niledatabase/client' ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/auth/api-reference/auth/sign-in-to-the-application This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/ai-embeddings/embeddin-models/google This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Import and Configure Nile Instance Source: https://www.thenile.dev/docs/auth/getting-started/installation Initializes the Nile server instance with specified extensions, such as Next.js. This step is necessary for setting up the authentication flow within your application. ```javascript import { Nile } from '@niledatabase/server' import { nextJs } from '@niledatabase/nextjs' export const nile = Nile({ extensions: [nextJs] }); ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/fireworks This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Initialize New Prisma Project with TypeScript Source: https://www.thenile.dev/docs/getting-started/schema_migrations/prisma This snippet covers the initial setup for a new project using Prisma and TypeScript. It includes creating a project directory, initializing npm, installing and configuring TypeScript, and installing and initializing Prisma with a PostgreSQL datasource provider. ```bash mkdir hello-prisma cd hello-prisma # Initialize a new npm project npm init -y # Install and initialize typescript npm install typescript tsx @types/node --save-dev npx tsc --init # Install and initialize Prisma npm install prisma --save-dev npx prisma init --datasource-provider postgresql ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/ai-embeddings/pg_vector This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/open_ai This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Get Started with NextJS Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/cohere This section guides users on integrating Nile with NextJS applications. It covers setting up the environment and basic connection patterns. ```javascript // Example NextJS setup for Nile // import { Pool } from 'pg'; // const pool = new Pool({ // user: 'your_user', // host: 'your_host', // database: 'your_database', // password: 'your_password', // port: 5432, // }); // // export async function GET(request) { // const res = await pool.query('SELECT NOW()'); // return Response.json({ time: res.rows[0].now }); // } ``` -------------------------------- ### Get Started with Drizzle Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/deepinfra This section guides users on integrating Nile with Drizzle ORM for database operations. It covers schema definition and querying. ```typescript import { pgTable, serial, text } from 'drizzle-orm/pg-core'; import { drizzle } from 'drizzle-orm/postgres-js'; import postgres from 'postgres-js'; const client = postgres("postgres://user:password@host:port/database"); export const db = drizzle(client); export const users = pgTable('users', { id: serial('id').primaryKey(), name: text('name'), email: text('email').notNull().unique() }); async function main() { const users = await db.select().from(users); console.log(users); } ``` -------------------------------- ### Get Started with Drizzle Source: https://www.thenile.dev/docs/ai-embeddings/embedding-models/voyage This section guides users on integrating Nile with Drizzle ORM for database operations. It covers schema definition and querying. ```typescript import { pgTable, serial, text } from 'drizzle-orm/pg-core'; import { drizzle } from 'drizzle-orm/postgres-js'; import postgres from 'postgres-js'; const client = postgres("postgres://user:password@host:port/database"); export const db = drizzle(client); export const users = pgTable('users', { id: serial('id').primaryKey(), name: text('name'), email: text('email').notNull().unique() }); async function main() { const users = await db.select().from(users); console.log(users); } ```