Open nasoooor29 opened 4 months ago
i think the relation type may cause a headace for us if we want to infer it to go code, for me i reached this conclusion if the type is not a struct or map and it's a pointer we throw an error if it's one of the known concreate types we just parse them if it was a struct (not pointer to struct) we take the fields and add them to the parent example:
// input:
type MyCustomStruct struct {
Name string
Age int
inner MyInnerStruct
}
type MyInnerStruct struct {
InnerName string
InnerAge int
}
// output:
type ResultStruct struct {
Name string
Age int
InnerName string
InnerAge int
}
when i typed it i think we should not do this idea and just throw an error if there is an inner struct (not pointer to struct) because we won't be able to destructure the again when we retrive the data into the 2 or more nested structs
so im leaning into making a new collection for each struct or struct ptr
@pluja i have done a small prototype you can check it on this repo it almost works by generating the json there is only some remaining types, can you check it and tell me if i can continue or you can take the code to continue the implementation.
Performing CRUD operations on the collections
by this i mean i can create the collection from my code i tried to search or figure it out on my own but i wasn't able to
refrence
solutions:
create a external tool
implementing the API
as shown from the refrences the api-collections is already implemented in js and dart so we can make it something like this
type MyCustomStruct struct { Name string Age int etc string Nested *NestedStruct } type NestedStruct struct { AnotherField string }
func SetupDB(client *pocketbase.Client) error { val := MyCustomStruct{ Name: "", Age: 0, etc: "", Nested: &NestedStruct{ AnotherField: "", }, } res, err := client.CreateCollection("MyCustomCollection", val) if err != nil ...
}