File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,8 @@ const Nested =
7272 } ;
7373
7474 const del = async ( key : NestedKey ) : Promise < string > => {
75- return addOperation ( { op : "DEL" , key, value : null } ) ;
75+ const joinedKey = typeof key === "string" ? key : joinKey ( key ) ;
76+ return addOperation ( { op : "DEL" , key : joinedKey , value : null } ) ;
7677 } ;
7778
7879 const get = async ( key : NestedKey ) : Promise < PossiblyNestedValue > => {
@@ -165,6 +166,7 @@ const Nested =
165166 put,
166167 set : put ,
167168 putNested,
169+ settNested : putNested ,
168170 get,
169171 del,
170172 iterator,
Original file line number Diff line number Diff line change @@ -183,6 +183,17 @@ describe("Nested Database", () => {
183183 expect ( actualAB ) . to . equal ( 1 ) ;
184184 } ) ;
185185
186+ it ( "remove a nested value" , async ( ) => {
187+ await db . put ( [ "a/b" ] , 1 ) ;
188+ await db . put ( "a/c" , 2 ) ;
189+
190+ await db . del ( "a/b" )
191+ await db . del ( [ "a" , "c" ] )
192+
193+ const actual = await db . all ( ) ;
194+ expect ( actual ) . to . be . empty ( ) ;
195+ } ) ;
196+
186197 it ( "add a nested value - list syntax" , async ( ) => {
187198 const hash1 = await db . put ( [ "a" , "b" ] , 1 ) ;
188199 const hash2 = await db . put ( [ "a" , "c" ] , 2 ) ;
You can’t perform that action at this time.
0 commit comments