SRem removes the specified members from the set stored int the bucket at given bucket,key and items.
(bucket string, key []byte, items ...[]byte)
| 94 | |
| 95 | // SRem removes the specified members from the set stored int the bucket at given bucket,key and items. |
| 96 | func (tx *Tx) SRem(bucket string, key []byte, items ...[]byte) error { |
| 97 | if err := tx.checkTxIsClosed(); err != nil { |
| 98 | return err |
| 99 | } |
| 100 | |
| 101 | b, err := tx.db.bucketMgr.GetBucket(DataStructureSet, bucket) |
| 102 | if err != nil { |
| 103 | return err |
| 104 | } |
| 105 | bucketId := b.Id |
| 106 | if set, ok := tx.db.Index.Set.exist(bucketId); ok { |
| 107 | ok, err := set.SAreMembers(string(key), items...) |
| 108 | if err != nil { |
| 109 | return err |
| 110 | } |
| 111 | if !ok { |
| 112 | return ErrSetMemberNotExist |
| 113 | } |
| 114 | return tx.sPut(bucket, key, DataDeleteFlag, items...) |
| 115 | } |
| 116 | return ErrBucketNotFound |
| 117 | } |
| 118 | |
| 119 | // SAreMembers returns if the specified members are the member of the set int the bucket at given bucket,key and items. |
| 120 | func (tx *Tx) SAreMembers(bucket string, key []byte, items ...[]byte) (bool, error) { |