forked from valkey-io/valkey-glide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: TJ Zhang <[email protected]> Co-authored-by: TJ Zhang <[email protected]>
- Loading branch information
1 parent
5bef4df
commit 815e24c
Showing
9 changed files
with
320 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 | ||
*/ | ||
|
||
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */ | ||
import { BaseClient } from "src/BaseClient"; | ||
|
||
/** | ||
* An optional condition to the {@link BaseClient.geoadd} command. | ||
*/ | ||
export enum ConditionalChange { | ||
/** | ||
* Only update elements that already exist. Don't add new elements. Equivalent to `XX` in the Valkey API. | ||
*/ | ||
ONLY_IF_EXISTS = "XX", | ||
|
||
/** | ||
* Only add new elements. Don't update already existing elements. Equivalent to `NX` in the Valkey API. | ||
* */ | ||
ONLY_IF_DOES_NOT_EXIST = "NX", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ConditionalChange } from "../ConditionalChange"; | ||
|
||
/** | ||
* Optional arguments for the GeoAdd command. | ||
* | ||
* See https://valkey.io/commands/geoadd/ for more details. | ||
*/ | ||
export class GeoAddOptions { | ||
/** Valkey API keyword use to modify the return value from the number of new elements added, to the total number of elements changed. */ | ||
public static CHANGED_VALKEY_API = "CH"; | ||
|
||
private updateMode?: ConditionalChange; | ||
|
||
private changed?: boolean; | ||
|
||
/** | ||
* Default constructor for GeoAddOptions. | ||
* | ||
* @param updateMode - Options for handling existing members. See {@link ConditionalChange}. | ||
* @param latitude - If `true`, returns the count of changed elements instead of new elements added. | ||
*/ | ||
constructor(options: { | ||
updateMode?: ConditionalChange; | ||
changed?: boolean; | ||
}) { | ||
this.updateMode = options.updateMode; | ||
this.changed = options.changed; | ||
} | ||
|
||
/** | ||
* Converts GeoAddOptions into a string[]. | ||
* | ||
* @returns string[] | ||
*/ | ||
public toArgs(): string[] { | ||
const args: string[] = []; | ||
|
||
if (this.updateMode) { | ||
args.push(this.updateMode); | ||
} | ||
|
||
if (this.changed) { | ||
args.push(GeoAddOptions.CHANGED_VALKEY_API); | ||
} | ||
|
||
return args; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* Represents a geographic position defined by longitude and latitude. | ||
* The exact limits, as specified by `EPSG:900913 / EPSG:3785 / OSGEO:41001` are the | ||
* following: | ||
* | ||
* Valid longitudes are from `-180` to `180` degrees. | ||
* Valid latitudes are from `-85.05112878` to `85.05112878` degrees. | ||
*/ | ||
export class GeospatialData { | ||
private longitude: number; | ||
|
||
private latitude: number; | ||
|
||
/** | ||
* Default constructor for GeospatialData. | ||
* | ||
* @param longitude - The longitude coordinate. | ||
* @param latitude - The latitude coordinate. | ||
*/ | ||
constructor(longitude: number, latitude: number) { | ||
this.longitude = longitude; | ||
this.latitude = latitude; | ||
} | ||
|
||
/** | ||
* Converts GeospatialData into a string[]. | ||
* | ||
* @returns string[] | ||
*/ | ||
public toArgs(): string[] { | ||
return [this.longitude.toString(), this.latitude.toString()]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.