denodb
denodb copied to clipboard
Type 'string | number | boolean | Date | (() => FieldValue) | null' is not assignable to type 'FieldValue'.
I want to run readme Demo then throw this error
error: TS2322 [ERROR]: Type 'string | number | boolean | Date | (() => FieldValue) | null' is not assignable to type 'FieldValue'.
Type '() => FieldValue' is not assignable to type 'FieldValue'.
Type '() => FieldValue' is missing the following properties from type 'Date': toDateString, toTimeString, toLocaleDateString, toLocaleTimeString, and 37 more.
defaultValue: fieldDefaults[field],
~~~~~~~~~~~~
at https://deno.land/x/[email protected]/lib/translators/sql-translator.ts:144:19
The expected type comes from property 'defaultValue' which is declared here on type 'FieldOptions'
defaultValue: FieldValue;
~~~~~~~~~~~~
at https://deno.land/x/[email protected]/lib/data-types.ts:77:3
TS2339 [ERROR]: Property 'openPlugin' does not exist on type 'typeof Deno'. 'Deno.openPlugin' is an unstable API. Did you forget to run with the '--unstable' flag?
return Deno.openPlugin(localPath);
~~~~~~~~~~
at https://deno.land/x/[email protected]/mod.ts:69:15
Found 2 errors.
and my code
import { Database, DataTypes, Model } from "https://deno.land/x/denodb/mod.ts";
export const db = new Database("mysql", {
database: 'DATABASE',
host: "localhost",
username: "root",
password: "root123",
port:3306
});
export class Flight extends Model {
static table = 'flights';
static timestamps = true;
static fields = {
id: { primaryKey: true, autoIncrement: true },
departure: DataTypes.STRING,
destination: DataTypes.STRING,
flightDuration: DataTypes.FLOAT,
};
static defaults = {
flightDuration: 2.5,
};
}
db.link([Flight]);
await db.sync({ drop: true });
await Flight.create({
departure: 'Paris',
destination: 'Tokyo',
});
I use like this async () => await Flight.all(),
Please tell me where is my code problem ,thank.
deno 1.5.2
可以参考这里暂时解决 You can refer to here for a temporary solution https://github.com/eveningkid/denodb/pull/150/commits/abed3063dd92436ceb4f124227daee5ee6604b2d
谢谢你@xyb851 希望你的建议可以暂时解决@KuuBee的问题!:) 我最近没有空但是我快要解决这个问题了(可以看看#157) 感谢你们的耐心等待!