slothdb
slothdb copied to clipboard
Why interface + annotated class?
Is there a particular reason why slothdb works with an interface in addition to the annotated class to define entities? At first sight it seems somewhat duplicate effort required here?
Looks like a really nice solution overall though, thanks!
What do you mean by "interface" ? any entity extends BaseEntity to implement new behavior, but I don't recall using an interface somewhere in the code
I am talking about the example of how to use SlothDB:
interface IAuthor {
_id: string,
name: string
}
@SlothEntity('authors')
class AuthorEntity extends BaseEntity<IAuthor> {
@SlothURI('library', 'author')
_id: string = ''
@SlothField()
name: string = 'Unknown'
}
Isn't IAuthor
just defining the same things as the AuthorEntity
class? Or when would I use the IAuthor
interface further?
It's not, it only describes the original document structure inside CouchDB IIRC.
My point is, couldn't that be implied from the class and its annotations? (i.e. all attributes with an @SlothField and @SlothURI annotations will be related to the CouchDB)