MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / getListWithDefault

Method getListWithDefault

tx_list.go:111–120  ·  view source on GitHub ↗

getListWithDefault this function will get list, if list not exists, will create a new one.

(bucket string)

Source from the content-addressed store, hash-verified

109// this function will get list, if list not exists, will create
110// a new one.
111func (tx *Tx) getListWithDefault(bucket string) (*data.List, error) {
112 b, err := tx.db.bucketMgr.GetBucket(DataStructureList, bucket)
113 if err != nil {
114 return nil, err
115 }
116 bucketId := b.Id
117
118 // Ensure the list index exists before performing list operations
119 return tx.db.Index.List.GetWithDefault(bucketId), nil
120}
121
122// RPush inserts the values at the tail of the list stored in the bucket at given bucket,key and values.
123func (tx *Tx) RPush(bucket string, key []byte, values ...[]byte) error {

Callers 2

RPushMethod · 0.95
LPushMethod · 0.95

Calls 2

GetBucketMethod · 0.80
GetWithDefaultMethod · 0.45

Tested by

no test coverage detected