Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement firestore connection checks #10610

Merged
merged 1 commit into from
May 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/server/src/integrations/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
QueryType,
IntegrationBase,
DatasourceFeature,
ConnectionInfo,
} from "@budibase/types"
import { Firestore, WhereFilterOp } from "@google-cloud/firestore"

Expand All @@ -19,7 +20,7 @@ const SCHEMA: Integration = {
type: "Non-relational",
description:
"Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud.",
features: [],
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
email: {
type: DatasourceFieldType.STRING,
Expand Down Expand Up @@ -101,6 +102,18 @@ class FirebaseIntegration implements IntegrationBase {
})
}

async testConnection(): Promise<ConnectionInfo> {
try {
await this.client.listCollections()
return { connected: true }
} catch (e: any) {
return {
connected: false,
error: e.message as string,
}
}
}

async create(query: { json: object; extra: { [key: string]: string } }) {
try {
const documentReference = this.client
Expand Down