campvanilla / casualdb Goto Github PK
View Code? Open in Web Editor NEWSimple JSON "database" for Deno with type-safety! ⚡️
License: MIT License
Simple JSON "database" for Deno with type-safety! ⚡️
License: MIT License
Hey,
I am doing a blog project with Deno and Drash. Can I store millions of posts, perform millions of read, write requests? My blog is small now but once it will go big, I still want to use casualdb for its easy API.
Hi, screenshot with error:
https://user-images.githubusercontent.com/75129392/102114936-27d4f000-3e7e-11eb-9e7f-c51d92412a51.jpg
I think an in-memory DB like this can also benefit from having a functionality of expiring keys.
Like in redis, a TTL could be specified for the keys and the keys would be deleted (soft) after the time.
Code,
import { CasualDB } from "https://deno.land/x/[email protected]/mod.ts";
Looks like it's a problem with the std
library, but not so sure which one calls that.
I managed to get this working by cloning the repo and updating the imports to use either older versions or other URLs but I'm just letting you know that it looks like there are a few 404 errors now when trying to import.
eg.
error: Import 'https://deno.land/x/[email protected]/matches.js' failed: 404 Not Found
Imported from "file:///C:/Users/phocks/Sites/rise/lib/CasualDB/operator/collection.ts:1"
I changed to import matches from "https://deno.land/x/[email protected]/matches.js";
error: Uncaught Error: Import 'https://deno.land/[email protected]/fs/write_json.ts' failed: 404 Not Found
Imported from "file:///C:/Users/phocks/Sites/rise/lib/CasualDB/writeWorker.ts:1"
I changed to: import { writeJson } from 'https://deno.land/x/jsonfile/mod.ts';
etc.
The new tag did not appear on deno.land/x
Do you have the GitHub hook properly set up?
This might be because of renaming the master branch to main.
I'm getting a Uncaught Error: send failed because receiver is gone
error when I run the following:
import { CasualDB } from "https://deno.land/x/casualdb/mod.ts";
interface Schema {
items: Array<{
id: number
time: number;
version: string;
dateCreated: string;
dateModified: string;
blocks: Array<{
type: string;
data: {[key: string]: any};
}>;
}>;
}
const db = new CasualDB<Schema>();
await db.connect("./posts.json");
const data = await db.get<Schema["items"]>('items');
console.log(data.value())
I'm using the following to run the script:
deno run --allow-read --allow-write --unstable main.ts
deno --version
yields:
deno 1.1.2
v8 8.5.216
typescript 3.9.2
Any ideas? I'm a total noob with deno, so apologies if the solution is simple.
Steps to reproduce.
.ts
file.deno run --allow-read --allow-write --unstable .\index.ts
error: Uncaught Error: Cannot resolve module "file:///D:/source/denoPortfolio/database/writeWorker.ts"
at WorkerImpl.#poll ($deno$/web/workers.ts:198:17)
My source: https://gist.github.com/Tezza48/2618a1d52e894d68e79161afcfa098cf
About me:
I am a web game developer from England at a small studio, working in Typescript. I'm using Deno purely for for learning, currently working on a blog/portfolio.
Hi, I wanted to use casualdb in Deno with JavaScript instead of TypeScript, but it was giving me compiler errors.
Here's my JavaScript code:
import { CasualDB } from "https://deno.land/x/[email protected]/mod.ts";
// interface Schema {
// data: any
// }
const db = new CasualDB()
await db.connect('./db.json')
And here are the errors I'm getting:
error: TS2345 [ERROR]: Argument of type 'Object' is not assignable to parameter of type 'Schema'.
'Schema' could be instantiated with an arbitrary type which could be unrelated to 'Object'.
The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
return this._connector.write(updatedData);
~~~~~~~~~~~
at https://deno.land/x/[email protected]/mod.ts:32:34
TS2769 [ERROR]: No overload matches this call.
Overload 1 of 2, '(callbackfn: (value: Op, index: number, array: Op[]) => value is Op, thisArg?: any): Op[]', gave the following error.
Argument of type 'Function' is not assignable to parameter of type '(value: Op, index: number, array: Op[]) => value is Op'.
Type 'Function' provides no match for the signature '(value: Op, index: number, array: Op[]): value is Op'.
Overload 2 of 2, '(callbackfn: (value: Op, index: number, array: Op[]) => unknown, thisArg?: any): Op[]', gave the following error.
Argument of type 'Function' is not assignable to parameter of type '(value: Op, index: number, array: Op[]) => unknown'.
Type 'Function' provides no match for the signature '(value: Op, index: number, array: Op[]): unknown'.
const filtered = this.data.filter(predicateFunction);
~~~~~~~~~~~~~~~~~
at https://deno.land/x/[email protected]/operator/collection.ts:52:39
TS2345 [ERROR]: Argument of type 'U[]' is not assignable to parameter of type '(string | string[])[]'.
Type 'U' is not assignable to type 'string | string[]'.
Type 'keyof Op' is not assignable to type 'string | string[]'.
Type 'string | number | symbol' is not assignable to type 'string | string[]'.
Type 'number' is not assignable to type 'string | string[]'.
Type 'keyof Op' is not assignable to type 'string[]'.
Type 'U' is not assignable to type 'string[]'.
Type 'keyof Op' is not assignable to type 'string[]'.
Type 'string | number | symbol' is not assignable to type 'string[]'.
Type 'string' is not assignable to type 'string[]'.
const picked = pick(this.data, ...paths) as { [P in U]: Op[P] };
~~~~~~~~
at https://deno.land/x/[email protected]/operator/primitive.ts:24:36
Found 3 errors.
Porting the code to TypeScript doesn't throw any errors and works fine, creating the db.json file with an empty object as expected.
import { CasualDB } from "https://deno.land/x/[email protected]/mod.ts";
interface Schema {
data: any
}
const db = new CasualDB<Schema>()
await db.connect('./db.json')
I suspected it might be because of the missing type argument, but removing it from the TypeScript example didn't throw any errors, it worked just the same.
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.