@tigrisdata/astro
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Tigris Astro Integration

GitHub Workflow Status npm Twitter Follow Discord

💡 What is Tigris?

If you are first-time user of Tigris, read the Getting Started guide to cover the basics.

🔨 Installation

Install @tigrisdata/astro:

npm install @tigrisdata/astro
# yarn add @tigrisdata/astro

Add the following code to astro.config.mjs and replace the YOUR_TIGRIS_PROJECT_NAME, YOUR_TIGRIS_CLIENT_ID, and YOUR_TIGRIS_CLIENT_SECRET with the values from your Tigris project.

import { defineConfig } from "astro/config";
import tigris from "@tigrisdata/astro";

export default defineConfig({
  integrations: [
    tigris({
      branch: "main",
      projectName: "YOUR_TIGRIS_PROJECT_NAME",
      clientId: "YOUR_TIGRIS_CLIENT_ID",
      clientSecret: "YOUR_TIGRIS_CLIENT_SECRET",
    }),
  ],
});

Options

When you initialize the integration, you can pass all @tigrisdata/core options.

🚀 Getting Started

Tigris collections are available with the useTigrisCollection hook:

import { useTigrisCollection } from "@tigrisdata/astro";

Fetching All Documents

You can fetch (and filter) all documents from a collection using the findMany method:

---
import { useTigrisCollection } from "@tigrisdata/astro";
import { User } from "./types/User";

const userCollection = await useTigrisCollection<User>("users");
const usersCursor = await userCollection.findMany({});
const users = await usersCursor.toArray();
---

{users.map(user =>
<div>{user.name}</div>
)}

Fetching One Document

You can fetch one document from a collection using the findOne method:

---
import { useTigrisCollection } from "@tigrisdata/astro";
import { User } from "./types/User";

const userCollection = await useTigrisCollection<User>("users");
const user = await userCollection.findOne({
    filter: {
        id: "1234"
    }
});
---

<div>{user.name}</div>

👀 Want to learn more?

Feel free to check our documentation or jump into our Discord server.

Package Sidebar

Install

npm i @tigrisdata/astro

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

7.42 kB

Total Files

8

Last publish

Collaborators

  • leggetter
  • garrensmith
  • firsov
  • matt.ayres
  • ansariadil
  • ovaistariq
  • jigarjm
  • designcode87