Esempio n. 1
0
// Append appends value to the key-value pair in the database.
func (h *Handle) Append(key, value []byte) error {
	rv := C.unqlite_kv_append(h.db, unsafe.Pointer(&key[0]), C.int(len(key)), unsafe.Pointer(&value[0]), C.unqlite_int64(len(value)))
	if rv == C.UNQLITE_OK {
		return nil
	}
	return Errno(rv)
}
Esempio n. 2
0
// KvStore write a new record into the database. If the record does not exists, it is created. Otherwise, the new data chunk is appended to the end of the old chunk.
// See: http://unqlite.org/c_api/unqlite_kv_append.html
func (u *Unqlite) KvAppend(key []byte, value []byte) error {
	if rc := C.unqlite_kv_append(u.db, unsafe.Pointer(&key[0]), C.int(len(key)), unsafe.Pointer(&value[0]), C.unqlite_int64(len(value))); rc != C.UNQLITE_OK {
		return ErrCode(rc)
	}

	return nil
}
Esempio n. 3
0
// Append ...
func (db *Database) Append(key, value []byte) (err error) {
	res := C.unqlite_kv_append(db.handle,
		unsafe.Pointer(&key[0]), C.int(len(key)),
		unsafe.Pointer(&value[0]), C.unqlite_int64(len(value)))
	if res != C.UNQLITE_OK {
		err = UnQLiteError(res)
	}
	return
}
Esempio n. 4
0
func (u *Unqlite) KvAppend(key, value []byte) error {
	var k, v unsafe.Pointer
	if len(key) > 0 {
		k = unsafe.Pointer(&key[0])
	}
	if len(value) > 0 {
		v = unsafe.Pointer(&value[0])
	}
	e := C.unqlite_kv_append(u.db, k, C.int(len(key)), v, C.unqlite_int64(len(value)))
	return code2Error(e)
}