Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[FR] Public API to Detect FieldValue.increment()

Đang mở
#2,957 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@ehsannas đang làm issue này rồi.

Từ ngày 12/8/2025.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

api: firestore type: feature request

The Firebase Admin Node SDK currently does not provide a public API to detect if a value is a FieldValue.increment() object. This forces developers to rely on internal implementation details like checking for constructor.name === 'NumericIncrementTransform', which is fragile and may break with SDK updates.

Current Workaround

// Current approach relies on internal implementation
function hasFieldValueIncrement(value: unknown): boolean {
  return (
    typeof value === 'object' &&
    value.constructor &&
    value.constructor.name === 'NumericIncrementTransform'
  );
}

Problem

  1. Fragility: The NumericIncrementTransform class name is an internal implementation detail
  2. No Stability Guarantee: This approach may break in future SDK versions
  3. Lack of Documentation: No official way to detect increment operations

Requested Enhancement

Please provide a public API method to detect FieldValue.increment() objects, similar to how other Firebase features provide type guards.

Suggested API
import { FieldValue } from 'firebase-admin/firestore';

// Option 1: Static method on FieldValue
FieldValue.isIncrement(value: unknown): value is FieldValue

// Option 2: Dedicated type guard function
import { isIncrement } from 'firebase-admin/firestore';
isIncrement(value: unknown): value is FieldValue

Use Case

This is needed for:

  • Data validation pipelines that need to identify increment operations
  • Custom diffing systems that handle FieldValue operations differently
  • Development tools that analyze Firestore update patterns
  • Testing utilities that need to verify increment operations
Ngôn ngữ chính
TypeScript
Star
1.7k
Fork
419
Merge trung bình
4 ngày 20 giờ
Pull request đã merge (30 ngày)
16

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của firebase/firebase-admin-node

Tất cả issue của firebase/firebase-admin-node

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.