-
Notifications
You must be signed in to change notification settings - Fork 7
cn crud create
redraiment edited this page Jun 2, 2014
·
1 revision
获取了me.zzp.ar.Table
对象之后,可以调用Table#create(Object... args)
来添加新的记录(并且立即返回刚创建的记录)。
该方法采用“命名参数”,来突显每个值的含义。由于Java不支持命名参数,因此列名末尾允许带一个冗余的冒号,即“name:”与“name”是等价的;此外键值对顺序无关,即第三条名为“Jim”的僵尸记录也能成功创建。
Table Zombie = sqlite3.active("zombies");
Zombie.create("name:", "Ash", "graveyard:", "Glen Haven Memorial Cemetery");
Zombie.create("name", "Bob", "graveyard", "Chapel Hill Cemetery");
Zombie.create("graveyard", "My Fathers Basement", "name", "Jim");
此外,Table
还提供了create(Record o)
方法,即根据现有的记录创建新的记录,用于数据库之间的迁移非常方便。
- 博客:zzp.me
- 微博:@redraiment