GithubHelp home page GithubHelp logo

casualdb's People

Contributors

abinavseelan avatar allcontributors[bot] avatar jackfiszr avatar kebot avatar rheaditi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

casualdb's Issues

Support for TTL

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.

A number of imports are now missing

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.

Uncaught Error: send failed because receiver is gone

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.

[Bug] Quick usage example does not run.

Steps to reproduce.

  1. Create a blank .ts file.
  2. Paste in Quick Usage code with the correct import statement for CasualDB.
  3. Execute the code using deno run --allow-read --allow-write --unstable .\index.ts
  4. Observe the following error:
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.

Using casualdb with JavaScript yields compiler errors

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.