当我尝试在Ionic Orm中创建连接时,会抛出以下错误:
未设置驱动程序选项(存储)。请将其设置为执行与数据库的连接
以下是我在 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));
答案 0 :(得分:1)
您需要在驱动程序选项中指定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