Git Product home page Git Product logo

Comments (5)

TokenChingy avatar TokenChingy commented on May 23, 2024 1

Actually never mind, I was using DATA_TYPE.string and not DATA_TYPES.STRING. Could you possibly make the documentation better? I'm having to dig into the source code to get answers.

EDIT: If I have time, and find this works well, I'll make a PR for documentation if that's okay?

from denodb.

eveningkid avatar eveningkid commented on May 23, 2024

Hey Jason,

So I think you're right, the problem seems that you're trying to convert Model[] to typeof Model[] which is not the same.

Model[] means a list of instances of Model. However, when you define a model, it's actually a class with static attributes, not an instance of that model.

What you could try to do is to replace:

const models: Model[] = [];

With:

const models: typeof Model[] = [];

I will create a more specific type for that, like type ModelSchema = typeof Model.
I hope this does the trick for you! Let me know if it doesn't.

Thanks for using DenoDB and giving me some feedback :)

from denodb.

TokenChingy avatar TokenChingy commented on May 23, 2024

Oh yea, that makes a lot of sense now. Got it, that got it working sort of. I've now encountered this error:

error: Uncaught TypeError: table[type] is not a function
      instruction = table[type](...fieldNameArgs);
                               ^
    at addFieldToSchema (https://deno.land/x/denodb/lib/helpers/fields.ts:30:32)
    at TableBuilder._fn (https://deno.land/x/denodb/lib/model-initializer.ts:39:13)
    at TableBuilder.toSQL (https://deno.land/x/dex/lib/schema/tablebuilder.js:45:12)
    at SchemaCompiler_PG.createTable (https://deno.land/x/dex/lib/schema/compiler.js:89:25)
    at SchemaCompiler_PG.toSQL (https://deno.land/x/dex/lib/schema/compiler.js:72:26)
    at SchemaBuilder.toSQL (https://deno.land/x/dex/lib/schema/builder.js:81:43)
    at SchemaBuilder.Target.toQuery (https://deno.land/x/dex/lib/interface.js:9:21)
    at SchemaBuilder.toString (https://deno.land/x/dex/lib/schema/builder.js:77:15)
    at ModelInitializer.init (https://deno.land/x/denodb/lib/model-initializer.ts:54:9)
    at async Function._createInDatabase (https://deno.land/x/denodb/lib/model.ts:68:5)

from denodb.

eveningkid avatar eveningkid commented on May 23, 2024

I made an update with 714a04d.
For the second issue, it seems to be related to your model fields types.

I spend as much time as I can on my free time for this.
So you're obviously very welcome to contribute! Would be really great :)

from denodb.

eveningkid avatar eveningkid commented on May 23, 2024

Also, just added another commit (5d4b631) that should bring some hints this time when you type DATA_TYPES.something.

If you reload the library, you should get the update!

from denodb.

Related Issues (20)

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.