li6185377 / LKDBHelper-SQLite-ORM

全自动的插入,查询,更新,删除, an automatic database operation thread-safe and not afraid of recursive deadlock
MIT License
1.21k stars 288 forks source link

NSSet可以支持吗? #139

Closed dsencheng closed 5 years ago

dsencheng commented 5 years ago

NSSet可以支持吗?

li6185377 commented 5 years ago

目前不支持,需要你自己转义下

/***
 *  @brief      overwrite in your models,return insert sqlite table data
 *
 *
 *  @return     property the data after conversion
 */
- (nullable id)userGetValueForModel:(LKDBProperty *)property;

/***
 *  @brief  overwrite in your models,return insert sqlite table data
 *
 *  @param  property        will set property
 *  @param  value           sqlite value (NSString(NSData UTF8 Coding) or NSData)
 */
- (void)userSetValueForModel:(LKDBProperty *)property value:(nullable id)value;
dsencheng commented 5 years ago

我是这样写的,崩溃了。"目前LKDB 还不支持 循环引用。 比如 A 持有 B, B 持有 A,这种的存储"。 Demo中的这两个方法没有断点到是为什么呢? 可以帮忙写个示例吗?

    - (id)userGetValueForModel:(LKDBProperty *)property {
        if ([property.sqlColumnName isEqualToString:@"doctorIdSet"]) {
            return self.doctorIdSet.allObjects;
        }
        return nil;
    }

    - (void)userSetValueForModel:(LKDBProperty *)property value:(id)value {
        if ([property.sqlColumnName isEqualToString:@"doctorIdSet"]) {
            [self.doctorIdSet addObjectsFromArray:value];
        }
    }

    - (NSMutableSet *)doctorIdSet {
        if (!_doctorIdSet) {
            _doctorIdSet = [NSMutableSet set];
        }
        return _doctorIdSet;
    }