当我尝试在 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));
您需要在驱动程序选项中指定 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