Skip to content

Commit

Permalink
Add an example code for map.removeAll method [API-15] (#1369)
Browse files Browse the repository at this point in the history
* add an example code for map.removeAll method

* add copyright and fix import problem
  • Loading branch information
fatihozer0 committed Sep 20, 2022
1 parent 8fd6c5d commit cae0c7d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions code_samples/map_removeAll_sample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2008-2022, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

const { Client, Predicates } = require('hazelcast-client');

(async () => {
const client = await Client.newHazelcastClient();
const map = await client.getMap('my-distributed-map');

for (let i = 0; i < 10 ; i++) {
await map.put('key' + i, i);
}
console.log('Map size before removing:', await map.size());

const predicate = Predicates.between('this', 3, 7);
await map.removeAll(predicate);

console.log('Map size after removing:', await map.size());

await client.shutdown();
})().catch(err => {
console.error('Error occurred:', err);
process.exit(1);
});

0 comments on commit cae0c7d

Please sign in to comment.