Skip to content

Commit cae0c7d

Browse files
authored
Add an example code for map.removeAll method [API-15] (#1369)
* add an example code for map.removeAll method * add copyright and fix import problem
1 parent 8fd6c5d commit cae0c7d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

code_samples/map_removeAll_sample.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2008-2022, Hazelcast, Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
'use strict';
17+
18+
const { Client, Predicates } = require('hazelcast-client');
19+
20+
(async () => {
21+
const client = await Client.newHazelcastClient();
22+
const map = await client.getMap('my-distributed-map');
23+
24+
for (let i = 0; i < 10 ; i++) {
25+
await map.put('key' + i, i);
26+
}
27+
console.log('Map size before removing:', await map.size());
28+
29+
const predicate = Predicates.between('this', 3, 7);
30+
await map.removeAll(predicate);
31+
32+
console.log('Map size after removing:', await map.size());
33+
34+
await client.shutdown();
35+
})().catch(err => {
36+
console.error('Error occurred:', err);
37+
process.exit(1);
38+
});
39+

0 commit comments

Comments
 (0)