Adam Harris
Adam Harris
Explore posts from servers
DDeno
Created by Adam Harris on 9/26/2024 in #help
In a deno/npm hybrid monorepo, what are the options for importing a deno member from a npm member?
@dsherret - thanks very much for this!
3 replies
XXata
Created by Adam Harris on 9/4/2024 in #help
Problems setting up Drizzle ORM with HTTP client via client/cli@ne
@tsg thanks for the confirmation - it seems that the generated xata.ts was pointing to a previous (next) version of the @Xata.io/client. So when I followed your instructions (in addition to clearing out the node_modules) the type error has gone away. thanks again for your help! 👍
12 replies
XXata
Created by Adam Harris on 9/4/2024 in #help
Problems setting up Drizzle ORM with HTTP client via client/cli@ne
@tsg basically, even with the @xata/io/client@next version in the package.json, we're still getting errors of the form ts: '"@xata.io/client"' has no exported member named 'getDeployPreviewBranch'. Did you mean 'getPreviewBranch'? in xata.ts
12 replies
XXata
Created by Adam Harris on 9/4/2024 in #help
Problems setting up Drizzle ORM with HTTP client via client/cli@ne
Hi @tsg just wondering if there has been any progress with this (or eg do you have a github issue that I can watch) ? We just switched to using pnpm in our monorepo and the issue has come back. We are currently stuck until this is fixed... Our package.json looks like this:
"@xata.io/cli": "^0.0.0-next.veed33633c02b9411aecf8f69d8c94071c9257c12",
"@xata.io/client": "^0.0.0-next.veed33633c02b9411aecf8f69d8c94071c9257c12"
"@xata.io/cli": "^0.0.0-next.veed33633c02b9411aecf8f69d8c94071c9257c12",
"@xata.io/client": "^0.0.0-next.veed33633c02b9411aecf8f69d8c94071c9257c12"
12 replies
XXata
Created by Adam Harris on 9/6/2024 in #help
⨯ FetcherError: dbname: invalid branch name when using client@next ts sdk
@tsg yes, that was it - thank you!
11 replies
XXata
Created by Adam Harris on 9/6/2024 in #help
Xata internal postgres fields - can I rely on them?
ok, that's promising!, but I'm still stuck with an invalid branch name error (https://discord.com/channels/996791218879086662/1281543310753927270), so I can't check, unfortunately...
8 replies
XXata
Created by Adam Harris on 9/6/2024 in #help
⨯ FetcherError: dbname: invalid branch name when using client@next ts sdk
@emily how do I check if postgres is enabled on a branch? I definitely enabled it when I initially created the db, but since then I created a new dev branch to rule out a bug due to a branch name containing hyphens. Now I can't see any flags in the UI indicating whether postgres is enabled...
11 replies
XXata
Created by Adam Harris on 9/6/2024 in #help
⨯ FetcherError: dbname: invalid branch name when using client@next ts sdk
Hi @emily thanks for the response. I'm instantiating the client via:
import { XataClient } from "@/xata";

let instance: XataClient | undefined = undefined;

// Seems to fix a bug in the xata client where apiKey and branch are not set
export const getXataClient = () => {
if (instance) return instance;
const apiKey = process.env.XATA_API_KEY;
if (!apiKey) {
throw new Error("XATA_API_KEY not set");
}
const branch = process.env.XATA_BRANCH;
if (!branch) {

throw new Error("XATA_BRANCH not set");
}
const databaseURL = process.env.XATA_DATABASE_URL;
if (!databaseURL) {

throw new Error("XATA_DATABASE_URL not set");
}
instance = new XataClient({
apiKey,
branch,
databaseURL,
});
return instance;
};
import { XataClient } from "@/xata";

let instance: XataClient | undefined = undefined;

// Seems to fix a bug in the xata client where apiKey and branch are not set
export const getXataClient = () => {
if (instance) return instance;
const apiKey = process.env.XATA_API_KEY;
if (!apiKey) {
throw new Error("XATA_API_KEY not set");
}
const branch = process.env.XATA_BRANCH;
if (!branch) {

throw new Error("XATA_BRANCH not set");
}
const databaseURL = process.env.XATA_DATABASE_URL;
if (!databaseURL) {

throw new Error("XATA_DATABASE_URL not set");
}
instance = new XataClient({
apiKey,
branch,
databaseURL,
});
return instance;
};
and accessing the data via a data access layer in a nextjs app. Here is the fn in the data access layer:
import { getXataClient } from "@/data/helpers";
import { TenantsRecord } from "@/xata";
import { SelectedPick } from "@xata.io/client";

const xata = getXataClient();

export async function getTenantBySlug(
slug: string
): Promise<SelectedPick<TenantsRecord, ["*"]> | null> {
const result = await xata.db.tenants.filter({ slug }).getFirst();
return result;
}
import { getXataClient } from "@/data/helpers";
import { TenantsRecord } from "@/xata";
import { SelectedPick } from "@xata.io/client";

const xata = getXataClient();

export async function getTenantBySlug(
slug: string
): Promise<SelectedPick<TenantsRecord, ["*"]> | null> {
const result = await xata.db.tenants.filter({ slug }).getFirst();
return result;
}
11 replies
XXata
Created by Adam Harris on 9/4/2024 in #help
Problems setting up Drizzle ORM with HTTP client via client/cli@ne
@tsg great - that’s what I resorted to, thanks very much for the clarification!
12 replies
XXata
Created by Adam Harris on 9/4/2024 in #help
Problems setting up Drizzle ORM with HTTP client via client/cli@ne
Hi @tsg thanks very much for your quick response! I followed your steps and this does result in having the correctly installed @next sdk, and the generated xata.ts now has no import errors. However the generated xata.ts still doesn't define getXataClient... Do you have a suggested workaround for this?
12 replies