0
내 CouchModel (TSCAssetUploadDO)이 첨부 파일을 저장했지만 속성을 저장하지 못했습니다. 이 같은 문서에 발생되는TouchDB가 첨부 파일을 저장하지만 속성을 저장하지 않습니다.
TSCAssetUploadDO *assetDO = [[TSCAssetUploadDO alloc] initWithNewDocumentInDatabase: _localAssetUploadDatabase];
NSData *data = UIImageJPEGRepresentation(contact.avatar, 1.0); // may need to resize.
NSString *attachmentName = [docID stringByAppendingString:@".jpg"];
[assetDO createAttachmentWithName:attachmentName type:@"image/jpeg" body:data];
assetDO.relatedDocID = docID;
assetDO.docType = @"contact";
RESTOperation *op2 = [assetDO save];
//[op2 wait]; originally thought that making it sync may work
[op2 onCompletion:^{
if (op2.error) NSLog(@"ERROR [TOUCHDB] %@", op2.error);
else
{
NSLog(@"YES! it saved");
}
if (completionBlock)
{
completionBlock(op2.error, contact);
}
//[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationDataUpdated object:nil];
}];
(저장 한 첨부 파일,하지만 DOCTYPE 및 relatedDocID 같은 프로퍼티) 아래
{
"_id": "D50ED630-34ED-4A02-A9C8-204E79A0648B",
"_rev": "1-b0ce9eaa1fb2f86dc9ae619e27ffe1ea",
"_attachments": {
"QSPNGC665.jpg": {
"content_type": "image/jpeg",
"revpos": 1,
"digest": "md5-u9V0rgoSRN5cUW2T3xh0hw==",
"length": 117500,
"stub": true
}
}
}
난 그냥 사용 CouchModel 없습니다.
@interface TSCAssetUploadDO: CouchModel
@property(nonatomic,retain) NSString *relatedDocID;
@property(nonatomic,retain) NSString *docType;//entity or contact
@property bool *toProcess;
@property (retain) NSDate* created_at;
@end
@implementation TSCAssetUploadDO
- (NSDictionary*) propertiesToSave {
// Initialize created_at the first time the document is saved:
if (self.created_at == nil)
self.created_at = [NSDate date];
return [super propertiesToSave];
}
@end
내가 잘못 했나요?