Thanks for your quick reply. I was about to head down this road and your
response told me I was headed in the right direction.
Ended up making a class method to encapsulate creating the composite
document ID. My creation class method looks similar to....
+ (instancetype)newMyModelWithSubtype:(NSString*)subtype
inDatabase:(CBLDatabase*)database
{
NSString *modelID = [MyModelClass documentIDForSubtype:subtype];
CBLDocument *modelDocument = [database documentWithID:modelID];
MyModelClass *newModel = [MyModelClass modelForDocument:modelDocument];
return newModel
}
- (void)awakeFromInitializer
{
[self setValue:@"my-model" ofProperty:@"type"];
}
On Tuesday, February 2, 2016 at 3:27:40 PM UTC-5, Jens Alfke wrote:
>
> In your situation I suggest not using +modelForNewDocumentInDatabase: at
> all. Instead create the docID first, then get a (new) document for it, then
> get the model for that document:
>
> NSString* newDocID = …whatever you want, incorporating some sort
> of UUID…;
> CBLDocument* doc = [_db documentWithID: newDocID];
> MySubclass *model = [MySubclass modelForDocument: doc];
>
> —Jens
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/8333cd14-7c0e-49e1-99a0-4c184f81077e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.