starlanestudios / cirql Goto Github PK
View Code? Open in Web Editor NEW๐ง A flexible SurrealDB ORM & query builder with Zod powered validation ๐๏ธโโ๏ธ
Home Page: https://cirql.starlane.studio/
License: MIT License
๐ง A flexible SurrealDB ORM & query builder with Zod powered validation ๐๏ธโโ๏ธ
Home Page: https://cirql.starlane.studio/
License: MIT License
Describe the bug
Receiving error Uncaught ReferenceError: EventTarget is not defined
when importing or requiring cirql
.
Example
In my TypeScript project, I've installed cirql
, zod
, and ws
. However, when I attempt to import or require cirql
, I get this failure:
> const cirql = require('cirql')
Uncaught ReferenceError: EventTarget is not defined
at /home/gilbert/dev/ecmastuff/surreal/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/cirql/dist/cirql.umd.cjs:4:22
at /home/gilbert/dev/ecmastuff/surreal/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/cirql/dist/cirql.umd.cjs:1:681
at Object.<anonymous> (/home/gilbert/dev/ecmastuff/surreal/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/cirql/dist/cirql.umd.cjs:1:892)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
The above was run in the node
repl. I receive the same error when I run import cirql from 'cirql'
in my TypeScript file and execute it using npx ts-node FILE
. This also happens when I run import cirql from 'cirql'
in the TS repl (via pnpm exec ts-node
) after I attempt introspection on the cirql
object. I do not have a tsconfig.json
file, so this is the default configuration.
Expected behavior
I expect to be able to import the module.
Environment:
Describe the bug
db.ready() throws the following error:
He {
type: 'error',
defaultPrevented: false,
cancelable: false,
timeStamp: 3265.9472999982536
}
Example
// src/lib/server/db.ts
import { Cirql } from 'cirql';
import {
SURREALDB_NS,
SURREALDB_DB,
SURREALDB_URL,
SURREALDB_USER,
SURREALDB_PASS,
} from "$env/static/private";
import { dev } from '$app/environment';
import { log } from '$lib/logger';
//import { withTimeout } from '$lib/utils';
declare global {
var surrealdb: Cirql
}
export let db = global.surrealdb;
export async function conectDB() {
if (db) return;
log.warn('creating new connection to db!');
try {
db = new Cirql({
connection: {
endpoint: SURREALDB_URL,
namespace: SURREALDB_NS,
database: SURREALDB_DB,
},
credentials: {
user: SURREALDB_USER,
pass: SURREALDB_PASS,
}
});
await db.ready();
// await withTimeout(db.ready(), 'db connection timed out', 5000);
if (dev) global.surrealdb = db;
log.info('db connected ');
} catch (error) {
log.error('connecting to db:', error);
}
}
Expected behavior
for that to not err out ig hands ๐คทโโ๏ธ
Environment:
surrealdb.js runs in a browser. This should too?
Describe the bug
I had a user schema with the following
import { RecordSchema } from "cirql"
import * as cirql from "cirql"
import { z } from "zod"
import db from "../modules/DatabaseModule"
export const UserSchema = RecordSchema.extend({
name: z.string(),
email: z.string().email(),
username: z.string(),
password: z.string(),
phoneNumber: z.string(),
verified: z.boolean().default(false),
})
export type User = z.infer<typeof UserSchema>;
On my request validation the phoneNumber wasn't compulsory but the zod schema made the phoneNumber compulsory...
When I tried to run the request I got the error below but to my surprise the data was present in the database
error: Query 1 failed to parse
- @0.phoneNumber: Required
code: "parse_failure"
Expected behavior
I expected the query not to run if the zod validation failed so the database wouldn't have any values
Environment:
Maintaining documentation takes a lot of time and energy, especially for a team as small as ours. As we are often working on many Open Source projects at once, we often find little time left to write and update our docs. For this reason we kindly ask the community and those interested to help expand the Cirql documentation.
Cirql is a very dynamic library which can be used in many ways, much like SurrealDB itself. Receiving community input is essential to describe and explain the various use-cases in which Cirql can be used. Naturally we will continue to update our documentation over time and review issues and PRs as frequently as we can. Currently we are seeking to cover the following topics:
raw()
and derivatives
RecordSchema
and EdgeSchema
.with()
, .withAny()
, and .withSchema()
You can visit the documentation repository here for further instructions on how you can help. Feel free to open issues on topics you would like to see covered, and submit new pages or improvements as PR's.
Thank you for your time and your interest in Cirql
Describe your feature request
I would prefer to use typia over zod because it is a smaller package and performs much faster type validation.
Are you willing to contribute this feature?
Yes, with direction on how to best incorporate this into the package.
Related pull request (if applicable)
not yet
Hi, I wanted to contribute to the API documentation but the comments on issue 6 are turned off. Can you sort this out? or let me know how to procceed?
Describe the bug
The eq()
function when passed a string returns an escaped string which prevents the usage of raw queries without using a provided method.
Example
eq('math::floor(12.133)')
output: [Symbol(Query Raw)]: "= \"math::floor(12.133)\""
Expected behavior
I expect the strings not to be escaped to allow you to use that without having to either use
eq(raw('math::floor(12.133)')
or
raw('= math::floor(12.133)')
I feel both of those options are are less clean to write. A change would also allow the use of any of the SurrealQL functions without having to rely on us having a helper method.
Environment:
Describe the bug
Module '"cirql"' has no exported member 'timeNow'.
Example
https://cirql.starlane.studio/docs/guide/basic-usage#raw-query-values--operators
const profile = await cirql.execute({
query: create('organisation').setAll({
name: 'Example',
isEnabled: eq('$enable'),
createdAt: eq(timeNow()) // time::now()
}),
schema: Organisation,
params: {
enable: true
}
});
Expected behavior
for it to work
Environment:
For now queries with parameters are rejected. I found this commit indicating that it should be possible, however no combination of specifying URL parameters after /sql
seemed to work.
Any help on decoding the Rust code and finding the correct way would be appreciated!
Describe your feature request
There isn't much available in your docs.. but the library appears to work great. Would be nice to know how to use it
Describe the bug
after installing cirql i got error with dependencies which are nested in next js 13:
Peer dependencies that should be installed:
@babel/core@">=7.13.0 <8.0.0" webpack@">=5.0.0 <6.0.0"
react-is@">= 16.8.0" ws@"*"
ts-node@>=10.0.0
I'm afraid such dependency error might seem like bugs in the future.
Environment:
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.