Documentation ¶
Overview ¶
yolodb is a simple in-memory database that supports basic CRUD operations.
Example ¶
package main import ( "fmt" yoloDB "simonwaldherr.de/go/golibs/yoloDB" ) func main() { // Erstellen einer neuen Datenbank db := yoloDB.NewDatabase() // Erstellen einer neuen Tabelle columns := []*yoloDB.Column{ {Name: "id", Typ: "int"}, {Name: "name", Typ: "string"}, {Name: "age", Typ: "int"}, } err := db.CreateTable("users", columns) if err != nil { panic(err) } // Einfügen von Datensätzen in die Tabelle data := map[string]interface{}{"id": 1, "name": "John Doe", "age": 30} err = db.Insert("users", data) if err != nil { panic(err) } data = map[string]interface{}{"id": 2, "name": "Jane Doe", "age": 32} err = db.Insert("users", data) if err != nil { panic(err) } // Auswählen von Datensätzen aus der Tabelle results, err := db.Select("users", []string{"name"}, []string{"age > 30"}) if err != nil { panic(err) } fmt.Println("Results:") for _, record := range results { fmt.Println(record) } }
Output: Results: map[name:Jane Doe]
Index ¶
- type Column
- type Database
- func (db *Database) CreateTable(name string, columns []*Column) error
- func (db *Database) Delete(name string, whereClauses []string) error
- func (db *Database) Insert(name string, data map[string]interface{}) error
- func (db *Database) Select(name string, columns []string, whereClauses []string) ([]map[string]interface{}, error)
- func (db *Database) Update(name string, data map[string]interface{}, whereClauses []string) error
- type Record
- type Table
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is the main struct of the database.
func (*Database) CreateTable ¶
CreateTable creates a new table in the database.
Click to show internal directories.
Click to hide internal directories.