Closed joyhope closed 1 year ago
What is exactly your question?
Yes, your understanding is correct. I think the Save()
method could be updated to take an any
object instead of a document to achieve what you suggest, but currently, you have to do as you said.
Let me know if you would like to work on that
I really like to have such a feature. It could be used easily. The user just defines Clover-supported structure, and such structure obj could be directly used by the DB.
Otherwise, the usage is a little awkward.
You can work on it, If you like. Unfortunately, I don't have the time to work on this, currently
@joyhope As I understand it, are you hope to have an ORM?
As per my understanding, the Save()
method should take an x parameter of any type instead of a Document object.
Then, if x is already a Document, it just uses that one, otherwise we call NewDocumentOf() and attempt to create a new document from the passed object
As I understand the clover gives a way, to add any struct object to the collection, through NewDocumentOf. It converts the struct to a map struct. It is very easy to use.
But I am unable to use this object to make updates and deletes. If I want to do this, I had to let the collection find the object, and then use the document.Set(..) to make an update.
I think there is a way to add _id to the structure or require the struct with "_id', so the structure is clover supported structure. And then find and update is easy to process.