Introduction Installation Projects Tables Inserts Searches Updates Deletes CLI Production Installation Conclusion

Inserts - Flaarum Tutorials

Insertion Method 1

The first method of insertion expects a map[string]interface{} for its data. Flaarum provides no statements for inserts. One would need to use a function call for insertions.

Sample Code

cl := flaarum.NewClient("127.0.0.1", "not-yet-ready", "first_proj")
toInsert := map[string]interface{} {
	"userid": 32,
	"roleid": 12,
}
retid, err := cl.InsertRowAny("user_roles", toInsert)
if err != nil {
	panic(err)
}
		

The flaarum lib expects the address of the database, its keystring (like a password) and the name of the project.

Insertion Method 2

The second method of insertion expects a map[string]string for its data. This introduces some comfort in some situations.

Sample Code

cl := flaarum.NewClient("127.0.0.1", "not-yet-ready", "first_proj")
toInsert := map[string]string {
	"userid": "32",
	"roleid": "12",
}
retid, err := cl.InsertRowStr("user_roles", toInsert)
if err != nil {
	panic(err)
}
		
< Previous Next >