Skip to content

Commit

Permalink
length to strLength
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-hui committed Sep 11, 2024
1 parent 38b3981 commit 0f4066c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
20 changes: 10 additions & 10 deletions dev/src/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,13 +671,13 @@ export abstract class Expr implements firestore.Expr {
*
* ```typescript
* // Get the length of the 'name' field
* Field.of("name").length();
* Field.of("name").strLength();
* ```
*
* @return A new `Expr` representing the length of the string.
*/
length(): Length {
return new Length(this);
strLength(): StrLength {
return new StrLength(this);
}

/**
Expand Down Expand Up @@ -1857,7 +1857,7 @@ class If extends Function implements FilterCondition {
/**
* @beta
*/
class Length extends Function {
class StrLength extends Function {
constructor(private expr: Expr) {
super('length', [expr]);
}
Expand Down Expand Up @@ -3492,13 +3492,13 @@ export function isNan(value: Expr | string): IsNan {
*
* ```typescript
* // Get the length of the 'name' field
* length("name");
* strLength("name");
* ```
*
* @param field The name of the field containing the string.
* @return A new {@code Expr} representing the length of the string.
*/
export function length(field: string): Length;
export function strLength(field: string): StrLength;

/**
* @beta
Expand All @@ -3507,16 +3507,16 @@ export function length(field: string): Length;
*
* ```typescript
* // Get the length of the 'name' field
* length(Field.of("name"));
* strLength(Field.of("name"));
* ```
*
* @param expr The expression representing the string to calculate the length of.
* @return A new {@code Expr} representing the length of the string.
*/
export function length(expr: Expr): Length;
export function length(value: Expr | string): Length {
export function strLength(expr: Expr): StrLength;
export function strLength(value: Expr | string): StrLength {
const valueExpr = value instanceof Expr ? value : Field.of(value);
return new Length(valueExpr);
return new StrLength(valueExpr);
}

/**
Expand Down
1 change: 1 addition & 0 deletions dev/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export {
not,
exists,
isNan,
strLength,
like,
regexContains,
regexMatch,
Expand Down
14 changes: 7 additions & 7 deletions types/firestore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3744,12 +3744,12 @@ declare namespace FirebaseFirestore {
*
* ```typescript
* // Get the length of the 'name' field
* Field.of("name").length();
* Field.of("name").strLength();
* ```
*
* @return A new `Expr` representing the length of the string.
*/
length(): Length;
strLength(): StrLength;

/**
* Creates an expression that performs a case-sensitive string comparison.
Expand Down Expand Up @@ -4569,7 +4569,7 @@ declare namespace FirebaseFirestore {
/**
* @beta
*/
export class Length extends Function {}
export class StrLength extends Function {}

/**
* @beta
Expand Down Expand Up @@ -5979,13 +5979,13 @@ declare namespace FirebaseFirestore {
*
* ```typescript
* // Get the length of the 'name' field
* length("name");
* strLength("name");
* ```
*
* @param field The name of the field containing the string.
* @return A new {@code Expr} representing the length of the string.
*/
export function length(field: string): Length;
export function strLength(field: string): StrLength;

/**
* @beta
Expand All @@ -5994,13 +5994,13 @@ declare namespace FirebaseFirestore {
*
* ```typescript
* // Get the length of the 'name' field
* length(Field.of("name"));
* strLength(Field.of("name"));
* ```
*
* @param expr The expression representing the string to calculate the length of.
* @return A new {@code Expr} representing the length of the string.
*/
export function length(expr: Expr): Length;
export function length(expr: Expr): StrLength;

/**
* @beta
Expand Down

0 comments on commit 0f4066c

Please sign in to comment.