【问题标题】:At Flutter, how to insert into sqflite table but the table doesn't have an id with auto increment integer?在 Flutter 中,如何插入 sqflite 表但该表没有自动递增整数的 id?
【发布时间】:2021-04-19 06:30:25
【问题描述】:

我看到 sqflite 数据库助手实例插入函数返回 Future<int>。我了解我的表是否使用 INTEGER PRIMARY KEY AUTO_INCREMENT 作为 id。但是如果我的 id 是STRING PRIMARY KEY NOT NULL 怎么办?函数会返回什么,因为函数坚持返回Future<int>?如何使返回值变为Future<String>?或者我可以忽略这个返回值吗?

【问题讨论】:

    标签: flutter auto-increment sqflite


    【解决方案1】:

    即使您使用文本主键,每个 SQLite 表都有一个整数行 id (https://www.sqlite.org/rowidtable.html)。这种情况下可以忽略返回值。

    【讨论】:

    • 啊,我明白了。我担心它实际返回那里的内容,或者将来是否会导致崩溃。好的,谢谢!
    猜你喜欢
    • 1970-01-01
    • 2019-06-23
    • 1970-01-01
    • 1970-01-01
    • 2021-12-26
    • 1970-01-01
    • 2023-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多