Simple ORM module for golang environment
- easy to use -> don't need many explanations -> clear to know how to use this library
- maintance -> support other data types later -> support other database (not sqlite3) later -> consideration of security
- test driven development using test case
- small unit test based development create, update, select, delete
- but I didn't make not all of _test.go files for the test
- i wrote detail use instructions in the main.go (sample)
-
create your struct
-
regist to orm engine -> it will return db object (db is object for orm) -> user need this db object to use ddl ro queries
-
how to use this module
1.define your own struct type your_struct struct { int, string, byte[] } 2.create table RegisterInOrmEngine <- let this method know the primary key index 3.insert InsertToTable 4.update UpdateRows + []SearchConditon + []TargetColumn 5.delete DeleteRows + []SearchConditon 6.search SearchRows + []SearchConditon
1. move to source folder
2. go run .
OR
run compiled file "orm_sample"
-
basic operations are working now
-
remains
- search and return result -> complete
- error define and handling -> basic handling complete
- review the usage convenience -> complete
- prevent misuse and test exception case -> remain
- error code, message define and mapping -> remain
- search conditon with time -> remain
-
big change of design
- struct in struct model
- I was preparing every struct which want to be store in the db have orm_engin inside but it was changed because of the go can't access to another packages struct
- interface model
- golang don't have file for each class so the code is not seperated well so I did't use this model
- controller model
- orm controller (crud) do the request of the struct.
- struct in struct model
-
hard problems during making this
- making common function for search -> deep understand of interface and get the element of pointer by Elem() method
- runtime variable declare and mapping to sqlite function -> type check and dynamically append to interface slice