Issue with passing Models[] into .link() method.
See original GitHub issueSo I have a situation here where I have a function for dynamically importing models into an array to then be linked to the database instance. I’m getting this error:
Type 'Model' is missing the following properties from type 'typeof Model': prototype, table, timestamps, fields, and 30 more.
database.link(await getModels("./models"));
So my function for dynamically importing is:
import { Model } from "https://deno.land/x/denodb/mod.ts";
import { walk } from "https://deno.land/std/fs/walk.ts";
const getModels = async (path: string): Promise<Model[]> => {
const models: Model[] = [];
for await (const file of walk(path)) {
if (file.isFile) {
const module = await import(`./${file.path}`);
models.push(module.default);
}
}
return Promise.resolve(models);
};
and the call to link is:
database.link(await getModels("./models"));
I did try:
const models: Model[] = await getModels("./models");
database.link(models);
but that had the same error.
I suspect it’s to do with the link method requiring models
to be of (typeof Model)[]
which is function
. But I can’t seem to get it to work.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
ASP.NET MVC Passing models by ActionLink - Stack Overflow
You can't pass model using ActionLink · MVC4 allows you to pass the model automatically through URL variables, which is seen my second...
Read more >Passing variables between pages using URL GET or POST ...
A query sting can be formatted with a link or a form can be used with get method to pass variables between pages....
Read more >Accessing Your Model's Data from a New Controller
In this section, you'll create a new `MoviesController` class and write code that retrieves the movie data and displays it in the browser ......
Read more >Pass data between destinations - Android Developers
To pass data between destinations, first define the argument by adding it to the destination that receives it by following these steps:.
Read more >Routing - Laravel - The PHP Framework For Web Artisans
Laravel route model binding provides a convenient way to automatically inject the model instances directly into your routes. For example, instead of injecting...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually never mind, I was using
DATA_TYPE.string
and notDATA_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?
Also, just added another commit (5d4b631d877eb6c960bc669939752756a8da1e35) that should bring some hints this time when you type
DATA_TYPES.something
.If you reload the library, you should get the update!