Comments (5)
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.
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.
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.
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.
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)
- Query always returns `undefined`. HOT 3
- Crashing when deployed to Deno Deploy HOT 2
- TLS connection failed with message: invalid peer certificate contents / PostgresError: no pg_hba.conf entry for host HOT 5
- Foreign key constraint name defaults to the name of the column
- Serialized Model option rather than classes?
- Can't import the latest version 1.0.40 HOT 5
- How to use denodb to connect to multiple postgresql databases having same models
- [Feature] Support SQL `SELECT DISTINCT`
- insert or update
- hash module break! HOT 4
- sqlite v3.1.3 not working on Windows
- Postgres Foreign Key is created with integer type by default HOT 2
- Timestamps
- Postgres connector makes the script unable to exit normally HOT 1
- How to set logging? HOT 2
- Postgresql: Timestamp fields adding hours each time records are updated
- Multiple Primary Key Exists HOT 1
- Some problems in model.ts
- A dependency is broken HOT 15
- Module not found "https://deno.land/std/node/events.ts". HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from denodb.