gpt4 book ai didi

ionic-framework - 在 ionic 2 中创建连接时出现 typeorm 问题

转载 作者:行者123 更新时间:2023-12-03 01:30:06 26 4
gpt4 key购买 nike

当我尝试在 Ionic Orm 中创建连接时,它会抛出以下错误:

Driver option (storage) is not set. Please set it to perform connection to the database

这是我在app.ts中连接的代码

createConnection({
driver: {
type: "sqlite",
database: "test"
},
entities: [
Products
],
autoSchemaSync: true,
}).then(connection => {
alert(connection);
let product = new Products();

}).catch(error => console.log(error));

最佳答案

需要在驱动选项中指定sqlite数据库的存储路径:

createConnection({
driver: {
type: "sqlite",
storage: "temp/test.db"
},
entities: [
Products
],
autoSchemaSync: true,
}).then(connection => {
alert(connection);
let product = new Products();
}).catch(error => console.log(error));

请参阅此处了解所有可用选项:https://typeorm.github.io/databases-and-drivers.html

关于ionic-framework - 在 ionic 2 中创建连接时出现 typeorm 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45326683/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com