snaplet / docs Goto Github PK
View Code? Open in Web Editor NEWSnaplet Documentation
Home Page: https://docs.snaplet.dev
Snaplet Documentation
Home Page: https://docs.snaplet.dev
I seems that snaplet doesn't look for the right place for config.
I am using:
[email protected]
@snaplet/[email protected]
I even added in package.json:
"@snaplet/seed": {
"config": "seed.config.ts"
},
My seed.config.ts
follows the documented instructions:
export default defineConfig({
adapter: () => {
const client = postgres(
"postgresql://postgres:[email protected]:54322/postgres"
)
return new SeedPostgres(client)
},
})
When I run bun seed.ts
I encounter problems:
4 | if (id) {
5 | return adapters[id];
6 | }
7 | const projectConfig = await getProjectConfig();
8 | if (projectConfig.adapter === undefined) {
9 | throw new Error("Adapter not found, please ensure that the 'adapter' key is set in `.snaplet/config.json`");
^
error: Adapter not found, please ensure that the 'adapter' key is set in `.snaplet/config.json`
at /Users/aymeric/Projects/trendful/new/node_modules/@snaplet/seed/dist/src/adapters/getAdapter.js:9:15
Bun v1.1.8 (macOS arm64)
I receive the error below when trying to run npx tsx prisma/seed/seed.ts
. I believe it's because one of the directories in the path starts with an 'n'.
The file path should be C:\Users\user\Documents\projects\nextjs_projects\project\prisma\seed\seed.config.ts
but is being parsed as C:\\Users\\user\\Documents\\projectsextjs_projects\\project\\prisma\\seed\\seed.config.ts
.
I changed the directory name nextjs_projects
to start with a different character and the command ran successfully.
{ _tag: 'SnapletError', code: 'SEED_CONFIG_NOT_FOUND', data: { path: 'C:\\Users\\user\\Documents\\projectsextjs_projects\\project\\prisma\\seed\\seed.config.ts' } }
OS: Windows 11
I'm trying to use snaplet ss share
but I'm getting a "0 successful snapshots found" message. I have two successful snapshots in my project.
Is it possible to disable the SQL logs when running the seed script?
e.g. these kind of logs
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '00000',
message: 'truncate cascades to table "refresh_tokens"',
file: 'tablecmds.c',
line: '1826',
routine: 'ExecuteTruncateGuts'
}
Hi, trying to generate 100,000+ rows with snaplet and output to a seed.sql file as a dryRun. The insert row gets truncated and I get a unexpected EOF
when trying to run the sql. Do you know what could be the issue please?
When using a postgres database with hyphenated table names, snaplet generates @snaplet/seed/dist/assets/userModels.js
with hyphenated Javascript property names that cause a syntax error during run-time because they don't have single or double quotes.
Here's the error
± % npx tsx seed.ts > supabase/seed.sql !2819
file:///Users/***/node_modules/@snaplet/seed/dist/assets/userModels.js:111
cms-for-whats-new: {
^
SyntaxError: Unexpected token '-'
at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:152:18)
at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:299:14)
Node.js v18.20.2
I am using @snaplet/[email protected]
My seed.config.ts
import { SeedPostgres } from "@snaplet/seed/adapter-postgres";
import { defineConfig } from "@snaplet/seed/config";
import postgres from "postgres";
export default defineConfig({
adapter: () => {
const client = postgres({
host: "localhost:54322",
port: 54322,
database: "postgres",
username: "postgres",
password: "postgres",
});
return new SeedPostgres(client);
},
select: [
// We don't alter any extensions tables that might be owned by extensions
"!*",
// We want to alter all the tables under public schema
"public*",
// We also want to alter some of the tables under the auth schema
"auth.users",
"auth.identities",
"auth.sessions",
],
});
My .snaplet/config.json
{
"adapter": "postgres"
}
Please reload your shell to refresh your PATH and start using snaplet
I got stuck on this part, I don't have the finger memory of refreshing PATH, so I got to googling, failing, etc. A whole detour just to get the CLI working
With the Snaplet CLI installed and configured, and having gone through the Snaplet Cloud onboarding experience, at this point you should have a snapshot ready...
But actually I landed on this page not having installed CLI, and then I had to look around the docs for the installation manual. Could have just been a link here ;)
Hello,
I'm trying to reproduce the plan connect example from the documentation and the behavior I'm observing isn't what I expected.
When I run
// Create a pool of 5 users for our workspace
const { users } = await seed.users((x) => x(5));
const workspacesNumber = 1;
// Create our workspace and connect all our users to it
const { workspace, workspace_member } = await seed.workspace((x) =>
x(workspacesNumber, () => ({
// Each workspace will have between 1 and 10 members
workspace_member: (x) => x(users.length)
}),
// Connect the workspace members to the pool of users we created
{ connect: { users }})
);
I get 10 users, 5 of which are linked to a workspace via workspace_member, whereas I expected to get only 5 users, all linked to a workspace.
If I remove the connect: { users } option, I get exactly the same result, which corresponds to my expectations since I'm now in the path connect case.
In my case, the connect option has no effect. Have I misunderstood how this option works? Or have I implemented the example incorrectly?
Thanks for your help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.