core.db #
fn base_decoder #
fn base_decoder(data []u8) !(encoder.Decoder, Base)
fn create #
fn create(args_ DBTableCreateArgs) !
create required tables for requested object
fn delete #
fn delete(args DBDeleteArgs) !
fn find #
fn find(args DBFindArgsI) ![][]u8
fn get #
fn get(args DBTableGetArgs) ![]u8
get the data from DB if you know the gid
fn remark_unserialize_binary #
fn remark_unserialize_binary(data []u8) !Remark
fn remark_unserialize_params #
fn remark_unserialize_params(p paramsparser.Params) !Remark
fn remarks_unserialize_binary #
fn remarks_unserialize_binary(data []u8) !Remarks
fn serializationtype_u8 #
fn serializationtype_u8(t SerializationType) u8
fn set #
fn set(args_ DBSetArgs) !
enum RemarkType #
enum RemarkType {
comment
log
audit
}
enum SerializationType #
enum SerializationType {
bin
json
heroscript
}
struct Base #
struct Base {
pub mut:
gid smartid.GID
params paramsparser.Params
version_base u8 = 1 // so we know how to do the serialize or unserialize
serialization_type SerializationType
name string
description string
remarks Remarks
mtime ourtime.OurTime // modification time
ctime ourtime.OurTime // creation time
}
fn (Base) bin_encoder #
fn (o Base) bin_encoder() !encoder.Encoder
returns bin encoder already populated with all base properties
fn (Base) json #
fn (mut o Base) json() string
fn (Base) params_add #
fn (mut o Base) params_add(text string) !
will merge the params
fn (Base) params_set #
fn (mut o Base) params_set(text string) !
fn (Base) remark_add #
fn (mut o Base) remark_add(args_ RemarkAddArgs) !Remark
fn (Base) serialize_kwargs #
fn (o Base) serialize_kwargs() !map[string]string
struct BaseFindArgs #
struct BaseFindArgs {
pub mut:
mtime_from ?ourtime.OurTime
mtime_to ?ourtime.OurTime
ctime_from ?ourtime.OurTime
ctime_to ?ourtime.OurTime
name string
}
struct DB #
struct DB {
pub mut:
cid smartid.CID
version u8 // 1 is binary, 2 is json, 3 is heroscript
circlename string
objtype string
sqlitedb sqlite.DB
datapath ?pathlib.Path
}
fn (DB) base_decoder_heroscript #
fn (db DB) base_decoder_heroscript(txt string) ![]DecoderActionItem
fn (DB) delete #
fn (db DB) delete(gid smartid.GID) !
fn (DB) delete_all #
fn (db DB) delete_all() !
fn (DB) find #
fn (db DB) find[T](args FindArgs[T]) ![]T
name string
fn (DB) find_base #
fn (db DB) find_base(base_args BaseFindArgs, args_ DBFindArgs) ![][]u8
find data based on find statements there are 2 parts to make up the find BaseFindArgs
mtime_from ?ourtime.OurTime
mtime_to ?ourtime.OurTime
ctime_from ?ourtime.OurTime
ctime_to ?ourtime.OurTime
name string
DBFindArgs, is the more generic part .
query_int map[string]int
query_string map[string]string
query_int_less map[string]int
query_int_greater map[string]int
fn (DB) get #
fn (db DB) get[T](gid smartid.GID) !T
fn (DB) get_data #
fn (db DB) get_data(gid smartid.GID) ![]u8
fn (DB) init #
fn (mut mydb DB) init() !
init creates the db file, creates an sqlite db connection pool, and adds the pool to the dbs map
fn (DB) new #
fn (db DB) new[T](args NewArgs[T]) !T
new creates a new root object with id and base It doesn't register the created object to the db, the returned object must still be added using the set method.
fn (DB) new_base #
fn (db DB) new_base(args DBBaseNewArgs) !Base
params string
name string
description string
mtime string// modification time
ctime string // creation time
fn (DB) serialize #
fn (db DB) serialize[T](obj T) ![]u8
this is the method to dump binary form
fn (DB) serialize_heroscript #
fn (db DB) serialize_heroscript[T](obj T) !string
serialize to heroscript
fn (DB) serialize_kwargs #
fn (db DB) serialize_kwargs[T](obj T) !map[string]string
serialize to heroscript
fn (DB) set #
fn (db DB) set[T](object T) !
set serializes and registers an object to the db with its index fields
fn (DB) set_data #
fn (db DB) set_data(args_ DBSetArgs) !
set data in database, need to pass the base obj as well
gid smartid.GID
objtype string // unique type name for obj class
index_int map[string]int
index_string map[string]string
data []u8 // if empty will do json
baseobj Base
fn (DB) unserialize #
fn (db DB) unserialize[T](data []u8) !T
this is the method to load binary form
fn (DB) unserialize_heroscript #
fn (db DB) unserialize_heroscript[T](txt string) ![]T
struct DBBaseNewArgs #
struct DBBaseNewArgs {
pub mut:
params string
name string
description string
mtime string // modification time
ctime string // creation time
remarks Remarks
}
struct DBDeleteArgs #
struct DBDeleteArgs {
pub mut:
cid smartid.CID @[required]
gid ?smartid.GID
objtype string @[required]
}
struct DBFindArgs #
struct DBFindArgs {
pub mut:
query_int map[string]int
query_string map[string]string
query_int_less map[string]int
query_int_greater map[string]int
}
struct DBSetArgs #
struct DBSetArgs {
pub mut:
gid smartid.GID
objtype string // unique type name for obj class
index_int map[string]int
index_string map[string]string
data []u8 // if empty will do json
baseobj Base
}
struct DBTableCreateArgs #
struct DBTableCreateArgs {
pub mut:
cid smartid.CID
objtype string // unique type name for obj class
index_int []string
index_string []string
}
struct DBTableGetArgs #
struct DBTableGetArgs {
pub mut:
gid smartid.GID @[required]
objtype string @[required]
}
struct DecoderActionItem #
struct DecoderActionItem {
pub:
base Base
params paramsparser.Params
}
struct FindArgs #
struct FindArgs[T] {
BaseFindArgs
pub mut:
object T
mtime_from ?ourtime.OurTime
mtime_to ?ourtime.OurTime
ctime_from ?ourtime.OurTime
ctime_to ?ourtime.OurTime
}
struct FindRemarkArgs #
struct FindRemarkArgs {
params_filter ?string
author ?smartid.GID
time_from ?ourtime.OurTime
time_to ?ourtime.OurTime
}
struct NewArgs #
struct NewArgs[T] {
pub mut:
params string // QUESTION: what are params for
name string // name of object
description string // description of object
mtime string // modification time
ctime string // creation time
object T // object that is being created
}
struct Remark #
struct Remark {
pub mut:
content string
time ourtime.OurTime
author ?smartid.GID
rtype RemarkType
params paramsparser.Params
}
fn (Remark) params_set #
fn (mut o Remark) params_set(text string) !
fn (Remark) params_add #
fn (mut o Remark) params_add(text string) !
will merge the params
fn (Remark) serialize_binary #
fn (o Remark) serialize_binary() []u8
fn (Remark) serialize_heroscript #
fn (r Remark) serialize_heroscript(gid string) !string
specifiy the gid for which we generate the heroscript output
struct RemarkAddArgs #
struct RemarkAddArgs {
pub mut:
content string
time ?ourtime.OurTime
author ?smartid.GID
rtype RemarkType
params string
}
struct Remarks #
struct Remarks {
pub mut:
remarks []Remark
}
fn (Remarks) remark_add #
fn (mut o Remarks) remark_add(args_ RemarkAddArgs) !Remark
fn (Remarks) serialize_binary #
fn (o Remarks) serialize_binary() []u8
fn (Remarks) find_remark #
fn (remarks Remarks) find_remark(args FindRemarkArgs) ![]Remark
fn (Remarks) serialize_heroscript #
fn (remarks Remarks) serialize_heroscript(gid string) !string
- fn base_decoder
- fn create
- fn delete
- fn find
- fn get
- fn remark_unserialize_binary
- fn remark_unserialize_params
- fn remarks_unserialize_binary
- fn serializationtype_u8
- fn set
- enum RemarkType
- enum SerializationType
- struct Base
- struct BaseFindArgs
- struct DB
- struct DBBaseNewArgs
- struct DBDeleteArgs
- struct DBFindArgs
- struct DBSetArgs
- struct DBTableCreateArgs
- struct DBTableGetArgs
- struct DecoderActionItem
- struct FindArgs
- struct FindRemarkArgs
- struct NewArgs
- struct Remark
- struct RemarkAddArgs
- struct Remarks