Comments (7)
麻烦详细描述需求,如何一对多、多对多等
from wcdb.
复杂的表结构交给后台处理吧
from wcdb.
比如Teacher class 和 Student class
一个 Teacher可能有多个Student
每个Student可能有多个Teacher
在创建模型的时候, 大概是:
@interface Teacher : NSObject
@property (nonatomic, copy) NSString *tid;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, strong) NSArray<Student *> *students;
@end
@interface Student : NSObject
@property (nonatomic, copy) NSString *sid;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, strong) NSArray<Teacher *> *teachers;
@end
用WCDB怎么创建各自的表和关系表呢,
CRUD怎么操作呢
from wcdb.
ORM没有纳入关系表。
如果你是希望保证students和teachers数据的对应关系,可以将其定义为BLOB类型,然后用transaction保证数据准确。
[database runTransaction:^BOOL{
Student* student = [[Student alloc] init] ;
student.name = @"newStudent";
Teacher* teacher = [[Teacher alloc] init] ;
teacher.name = @"newTeacher";
[teacher.students addObject:student]
[student.teachers addObject:teacher];
return [database insertOrReplaceObject:student into:@"students"]
&&[database insertOrReplaceObject:teacher into:@"teachers"];
}];
或者用trigger应该也可以。WCDB没有提供trigger的方便接口,可以使用 Core 接口,配合WINQ来实现。
正如 qingyunhe 所说,不建议在客户端使用复杂的表结构。
from wcdb.
android 是否可以提供一下orm
from wcdb.
@chenyunecjtu 这个问题不是讨论Android ORM,麻烦你新开一个Issue
from wcdb.
no reply
from wcdb.
Related Issues (20)
- 如何查看WCDB依赖的WCDBOptimizedSQLCipher版本对应的tag / 分支 / commit id HOT 2
- 运行在 iOS 17 真机上,Core.cpp 库 Crash HOT 4
- 为什么要设置SQLITE_MAX_VARIABLE_NUMBER为99 HOT 3
- 安卓的全文检索什么时候更新? HOT 1
- 'WCDB.swift', '~> 2.0.3' 真机运行12.5.5创建database时崩溃 HOT 2
- iOS 扩展应用,在APP Group共享文件夹,无法创建数据库 HOT 8
- WCDBSwift2.0.4无法创建虚拟表 HOT 2
- Xcode 15 crash HOT 3
- Cocoapods导入后 死活找不到头文件。 HOT 1
- Swift WCDB Debug模式下初始化crash HOT 3
- Build failed HOT 2
- how two write sql join on expression with winQ HOT 1
- WCDBOptimizedSQLCipher 无法下载 HOT 1
- 数据model可以同时遵循Codable和TableCodable么? HOT 1
- > ![image](https://user-images.githubusercontent.com/5007022/270093463-56885d67-5d82-4d58-84ac-b3d5d49f08b6.png)
- Database close HOT 1
- 关键字查找 HOT 4
- iOS12系列机型,app启动就carsh HOT 2
- new java version... HOT 1
- 什么时候支持arkTs? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wcdb.