Skip to content

Commit

Permalink
- rename "exists" method to "exist" for Hive(str).Store
Browse files Browse the repository at this point in the history
  • Loading branch information
Valodya committed Nov 3, 2022
1 parent 3d67522 commit 5c7ca2c
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 97 deletions.
4 changes: 2 additions & 2 deletions backendless.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ declare module Backendless {

delete(keys: Array<string>): Promise<void>;

exists(keys: Array<string>): Promise<number>;
exist(keys: Array<string>): Promise<number>;

touch(keys: Array<string>): Promise<void>;
}
Expand All @@ -350,7 +350,7 @@ declare module Backendless {

rename(newKeyName: string, overwrite?: boolean): Promise<void>;

exists(): Promise<boolean>;
exist(): Promise<boolean>;

getExpiration(): Promise<number>;

Expand Down
10 changes: 5 additions & 5 deletions src/hive/stores/base-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Utils from '../../utils'

export class HiveStore {

static STATIC_METHODS = ['keys', 'delete', 'exists', 'touch']
static STATIC_METHODS = ['keys', 'delete', 'exist', 'touch']

static registerType(hive) {
const context = { ...this, app: hive.app, hiveName: hive.hiveName }
Expand Down Expand Up @@ -68,14 +68,14 @@ export class HiveStore {
})
}

static exists(keys) {
static exist(keys) {
if (!Array.isArray(keys)) {
throw new Error('Keys must be provided and must be a list of strings.')
}

return this.app.request
.post({
url : `${this.app.urls.hiveStore(this.hiveName, this.TYPE)}/action/exists`,
url : `${this.app.urls.hiveStore(this.hiveName, this.TYPE)}/action/exist`,
data: keys
})
}
Expand All @@ -100,8 +100,8 @@ export class HiveStore {
return this.constructor.delete.call({ ...this, ...this.constructor }, [this.storeKey])
}

async exists() {
const result = await this.constructor.exists.call({ ...this, ...this.constructor }, [this.storeKey])
async exist() {
const result = await this.constructor.exist.call({ ...this, ...this.constructor }, [this.storeKey])

return !!result
}
Expand Down
20 changes: 10 additions & 10 deletions test/tsd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,14 +744,14 @@ function testHiveStores() {
promiseStoreKeysResult = Backendless.Hive(str).KeyValueStore.keys(storeKeysOptions);

promiseVoid = Backendless.Hive(str).KeyValueStore.delete(strArr);
promiseNumber = Backendless.Hive(str).KeyValueStore.exists(strArr);
promiseNumber = Backendless.Hive(str).KeyValueStore.exist(strArr);
promiseVoid = Backendless.Hive(str).KeyValueStore.touch(strArr);
}

function testGeneralInstance() {
promiseNumber = Backendless.Hive(str).KeyValueStore(str).delete();

promiseBoolean = Backendless.Hive(str).KeyValueStore(str).exists();
promiseBoolean = Backendless.Hive(str).KeyValueStore(str).exist();

promiseVoid = Backendless.Hive(str).KeyValueStore(str).rename(str);
promiseVoid = Backendless.Hive(str).KeyValueStore(str).rename(str, bool);
Expand Down Expand Up @@ -808,14 +808,14 @@ function testHiveStores() {
promiseStoreKeysResult = Backendless.Hive(str).ListStore.keys(storeKeysOptions);

promiseVoid = Backendless.Hive(str).ListStore.delete(strArr);
promiseNumber = Backendless.Hive(str).ListStore.exists(strArr);
promiseNumber = Backendless.Hive(str).ListStore.exist(strArr);
promiseVoid = Backendless.Hive(str).ListStore.touch(strArr);
}

function testGeneralInstance() {
promiseNumber = Backendless.Hive(str).ListStore(str).delete();

promiseBoolean = Backendless.Hive(str).ListStore(str).exists();
promiseBoolean = Backendless.Hive(str).ListStore(str).exist();

promiseVoid = Backendless.Hive(str).ListStore(str).rename(str);
promiseVoid = Backendless.Hive(str).ListStore(str).rename(str, bool);
Expand Down Expand Up @@ -903,14 +903,14 @@ function testHiveStores() {
promiseStoreKeysResult = Backendless.Hive(str).MapStore.keys(storeKeysOptions);

promiseVoid = Backendless.Hive(str).MapStore.delete(strArr);
promiseNumber = Backendless.Hive(str).MapStore.exists(strArr);
promiseNumber = Backendless.Hive(str).MapStore.exist(strArr);
promiseVoid = Backendless.Hive(str).MapStore.touch(strArr);
}

function testGeneralInstance() {
promiseNumber = Backendless.Hive(str).MapStore(str).delete();

promiseBoolean = Backendless.Hive(str).MapStore(str).exists();
promiseBoolean = Backendless.Hive(str).MapStore(str).exist();

promiseVoid = Backendless.Hive(str).MapStore(str).rename(str);
promiseVoid = Backendless.Hive(str).MapStore(str).rename(str, bool);
Expand Down Expand Up @@ -975,14 +975,14 @@ function testHiveStores() {
promiseStoreKeysResult = Backendless.Hive(str).SetStore.keys(storeKeysOptions);

promiseVoid = Backendless.Hive(str).SetStore.delete(strArr);
promiseNumber = Backendless.Hive(str).SetStore.exists(strArr);
promiseNumber = Backendless.Hive(str).SetStore.exist(strArr);
promiseVoid = Backendless.Hive(str).SetStore.touch(strArr);
}

function testGeneralInstance() {
promiseNumber = Backendless.Hive(str).SetStore(str).delete();

promiseBoolean = Backendless.Hive(str).SetStore(str).exists();
promiseBoolean = Backendless.Hive(str).SetStore(str).exist();

promiseVoid = Backendless.Hive(str).SetStore(str).rename(str);
promiseVoid = Backendless.Hive(str).SetStore(str).rename(str, bool);
Expand Down Expand Up @@ -1065,14 +1065,14 @@ function testHiveStores() {
promiseStoreKeysResult = Backendless.Hive(str).SortedSetStore.keys(storeKeysOptions);

promiseVoid = Backendless.Hive(str).SortedSetStore.delete(strArr);
promiseNumber = Backendless.Hive(str).SortedSetStore.exists(strArr);
promiseNumber = Backendless.Hive(str).SortedSetStore.exist(strArr);
promiseVoid = Backendless.Hive(str).SortedSetStore.touch(strArr);
}

function testGeneralInstance() {
promiseNumber = Backendless.Hive(str).SortedSetStore(str).delete();

promiseBoolean = Backendless.Hive(str).SortedSetStore(str).exists();
promiseBoolean = Backendless.Hive(str).SortedSetStore(str).exist();

promiseVoid = Backendless.Hive(str).SortedSetStore(str).rename(str);
promiseVoid = Backendless.Hive(str).SortedSetStore(str).rename(str, bool);
Expand Down
32 changes: 16 additions & 16 deletions test/unit/specs/hive/key-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ describe('Hive - Key Value Store', function() {
it('success with multi keys', async () => {
const request = prepareMockRequest(fakeResult)

const result = await Store.exists(['testKey1', 'testKey1'])
const result = await Store.exist(['testKey1', 'testKey1'])

expect(request).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/key-value/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/key-value/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : ['testKey1', 'testKey1']
})
Expand All @@ -155,16 +155,16 @@ describe('Hive - Key Value Store', function() {
it('fails when key(s) is invalid', async () => {
const errorMsg = 'Keys must be provided and must be a list of strings.'

await expect(() => Store.exists(undefined)).to.throw(errorMsg)
await expect(() => Store.exists(null)).to.throw(errorMsg)
await expect(() => Store.exists(false)).to.throw(errorMsg)
await expect(() => Store.exists(true)).to.throw(errorMsg)
await expect(() => Store.exists('')).to.throw(errorMsg)
await expect(() => Store.exists('key')).to.throw(errorMsg)
await expect(() => Store.exists(0)).to.throw(errorMsg)
await expect(() => Store.exists(123)).to.throw(errorMsg)
await expect(() => Store.exists(() => undefined)).to.throw(errorMsg)
await expect(() => Store.exists({})).to.throw(errorMsg)
await expect(() => Store.exist(undefined)).to.throw(errorMsg)
await expect(() => Store.exist(null)).to.throw(errorMsg)
await expect(() => Store.exist(false)).to.throw(errorMsg)
await expect(() => Store.exist(true)).to.throw(errorMsg)
await expect(() => Store.exist('')).to.throw(errorMsg)
await expect(() => Store.exist('key')).to.throw(errorMsg)
await expect(() => Store.exist(0)).to.throw(errorMsg)
await expect(() => Store.exist(123)).to.throw(errorMsg)
await expect(() => Store.exist(() => undefined)).to.throw(errorMsg)
await expect(() => Store.exist({})).to.throw(errorMsg)
})
})

Expand Down Expand Up @@ -241,19 +241,19 @@ describe('Hive - Key Value Store', function() {
const req1 = prepareMockRequest(1)
const req2 = prepareMockRequest(0)

const result1 = await store.exists(storeKey)
const result2 = await store.exists(storeKey)
const result1 = await store.exist(storeKey)
const result2 = await store.exist(storeKey)

expect(req1).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/key-value/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/key-value/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : [storeKey]
})

expect(req2).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/key-value/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/key-value/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : [storeKey]
})
Expand Down
32 changes: 16 additions & 16 deletions test/unit/specs/hive/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ describe('Hive - List Store', function() {
it('success with multi keys', async () => {
const request = prepareMockRequest(fakeResult)

const result = await Store.exists(['testKey1', 'testKey1'])
const result = await Store.exist(['testKey1', 'testKey1'])

expect(request).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/list/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/list/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : ['testKey1', 'testKey1']
})
Expand All @@ -156,16 +156,16 @@ describe('Hive - List Store', function() {
it('fails when key(s) is invalid', async () => {
const errorMsg = 'Keys must be provided and must be a list of strings.'

await expect(() => Store.exists(undefined)).to.throw(errorMsg)
await expect(() => Store.exists(null)).to.throw(errorMsg)
await expect(() => Store.exists(false)).to.throw(errorMsg)
await expect(() => Store.exists(true)).to.throw(errorMsg)
await expect(() => Store.exists('')).to.throw(errorMsg)
await expect(() => Store.exists('key')).to.throw(errorMsg)
await expect(() => Store.exists(0)).to.throw(errorMsg)
await expect(() => Store.exists(123)).to.throw(errorMsg)
await expect(() => Store.exists(() => undefined)).to.throw(errorMsg)
await expect(() => Store.exists({})).to.throw(errorMsg)
await expect(() => Store.exist(undefined)).to.throw(errorMsg)
await expect(() => Store.exist(null)).to.throw(errorMsg)
await expect(() => Store.exist(false)).to.throw(errorMsg)
await expect(() => Store.exist(true)).to.throw(errorMsg)
await expect(() => Store.exist('')).to.throw(errorMsg)
await expect(() => Store.exist('key')).to.throw(errorMsg)
await expect(() => Store.exist(0)).to.throw(errorMsg)
await expect(() => Store.exist(123)).to.throw(errorMsg)
await expect(() => Store.exist(() => undefined)).to.throw(errorMsg)
await expect(() => Store.exist({})).to.throw(errorMsg)
})
})

Expand Down Expand Up @@ -243,19 +243,19 @@ describe('Hive - List Store', function() {
const req1 = prepareMockRequest(1)
const req2 = prepareMockRequest(0)

const result1 = await store.exists(storeKey)
const result2 = await store.exists(storeKey)
const result1 = await store.exist(storeKey)
const result2 = await store.exist(storeKey)

expect(req1).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/list/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/list/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : [storeKey]
})

expect(req2).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/list/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/list/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : [storeKey]
})
Expand Down
32 changes: 16 additions & 16 deletions test/unit/specs/hive/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ describe('Hive - Map Store', function() {
it('success with multi keys', async () => {
const request = prepareMockRequest(fakeResult)

const result = await Store.exists(['testKey1', 'testKey1'])
const result = await Store.exist(['testKey1', 'testKey1'])

expect(request).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/map/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/map/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : ['testKey1', 'testKey1']
})
Expand All @@ -155,16 +155,16 @@ describe('Hive - Map Store', function() {
it('fails when key(s) is invalid', async () => {
const errorMsg = 'Keys must be provided and must be a list of strings.'

await expect(() => Store.exists(undefined)).to.throw(errorMsg)
await expect(() => Store.exists(null)).to.throw(errorMsg)
await expect(() => Store.exists(false)).to.throw(errorMsg)
await expect(() => Store.exists(true)).to.throw(errorMsg)
await expect(() => Store.exists('')).to.throw(errorMsg)
await expect(() => Store.exists('key')).to.throw(errorMsg)
await expect(() => Store.exists(0)).to.throw(errorMsg)
await expect(() => Store.exists(123)).to.throw(errorMsg)
await expect(() => Store.exists(() => undefined)).to.throw(errorMsg)
await expect(() => Store.exists({})).to.throw(errorMsg)
await expect(() => Store.exist(undefined)).to.throw(errorMsg)
await expect(() => Store.exist(null)).to.throw(errorMsg)
await expect(() => Store.exist(false)).to.throw(errorMsg)
await expect(() => Store.exist(true)).to.throw(errorMsg)
await expect(() => Store.exist('')).to.throw(errorMsg)
await expect(() => Store.exist('key')).to.throw(errorMsg)
await expect(() => Store.exist(0)).to.throw(errorMsg)
await expect(() => Store.exist(123)).to.throw(errorMsg)
await expect(() => Store.exist(() => undefined)).to.throw(errorMsg)
await expect(() => Store.exist({})).to.throw(errorMsg)
})
})

Expand Down Expand Up @@ -242,19 +242,19 @@ describe('Hive - Map Store', function() {
const req1 = prepareMockRequest(1)
const req2 = prepareMockRequest(0)

const result1 = await store.exists(storeKey)
const result2 = await store.exists(storeKey)
const result1 = await store.exist(storeKey)
const result2 = await store.exist(storeKey)

expect(req1).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/map/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/map/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : [storeKey]
})

expect(req2).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/map/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/map/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : [storeKey]
})
Expand Down
32 changes: 16 additions & 16 deletions test/unit/specs/hive/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ describe('Hive - Set Store', function() {
it('success with multi keys', async () => {
const request = prepareMockRequest(fakeResult)

const result = await Store.exists(['testKey1', 'testKey1'])
const result = await Store.exist(['testKey1', 'testKey1'])

expect(request).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/set/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/set/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : ['testKey1', 'testKey1']
})
Expand All @@ -155,16 +155,16 @@ describe('Hive - Set Store', function() {
it('fails when key(s) is invalid', async () => {
const errorMsg = 'Keys must be provided and must be a list of strings.'

await expect(() => Store.exists(undefined)).to.throw(errorMsg)
await expect(() => Store.exists(null)).to.throw(errorMsg)
await expect(() => Store.exists(false)).to.throw(errorMsg)
await expect(() => Store.exists(true)).to.throw(errorMsg)
await expect(() => Store.exists('')).to.throw(errorMsg)
await expect(() => Store.exists('key')).to.throw(errorMsg)
await expect(() => Store.exists(0)).to.throw(errorMsg)
await expect(() => Store.exists(123)).to.throw(errorMsg)
await expect(() => Store.exists(() => undefined)).to.throw(errorMsg)
await expect(() => Store.exists({})).to.throw(errorMsg)
await expect(() => Store.exist(undefined)).to.throw(errorMsg)
await expect(() => Store.exist(null)).to.throw(errorMsg)
await expect(() => Store.exist(false)).to.throw(errorMsg)
await expect(() => Store.exist(true)).to.throw(errorMsg)
await expect(() => Store.exist('')).to.throw(errorMsg)
await expect(() => Store.exist('key')).to.throw(errorMsg)
await expect(() => Store.exist(0)).to.throw(errorMsg)
await expect(() => Store.exist(123)).to.throw(errorMsg)
await expect(() => Store.exist(() => undefined)).to.throw(errorMsg)
await expect(() => Store.exist({})).to.throw(errorMsg)
})
})

Expand Down Expand Up @@ -242,19 +242,19 @@ describe('Hive - Set Store', function() {
const req1 = prepareMockRequest(1)
const req2 = prepareMockRequest(0)

const result1 = await store.exists(storeKey)
const result2 = await store.exists(storeKey)
const result1 = await store.exist(storeKey)
const result2 = await store.exist(storeKey)

expect(req1).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/set/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/set/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : [storeKey]
})

expect(req2).to.deep.include({
method : 'POST',
path : `${APP_PATH}/hive/${hiveName}/set/action/exists`,
path : `${APP_PATH}/hive/${hiveName}/set/action/exist`,
headers: { 'Content-Type': 'application/json' },
body : [storeKey]
})
Expand Down
Loading

0 comments on commit 5c7ca2c

Please sign in to comment.