Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

gcp-firestore

БесплатноБез исполняемых скриптовНе проверен

Build real-time applications with Google Cloud Firestore. Model data with collections and documents, execute queries with composite indexes, set up real-time…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

GCP Firestore

Overview

Cloud Firestore is a flexible, scalable NoSQL document database. It supports real-time synchronization, offline access, and scales automatically. Native mode (the default) has real-time listeners and offline client support; Datastore mode is server-only. Databases come in a Standard edition and an Enterprise edition (the latter also offers a MongoDB-compatible API).

Instructions

Core concepts

  • Document — a record containing fields (like a JSON object), identified by ID
  • Collection — a group of documents
  • Subcollection — a collection nested under a document
  • Reference — a pointer to a document or collection location
  • Real-time listener — streams live changes to documents or queries
  • Security Rules — declarative access control for client SDKs

Create a database and install the client

gcloud firestore databases create --location=nam5 --type=firestore-native
pip install google-cloud-firestore          # Python
npm install @google-cloud/firestore         # Node.js server SDK

Server libraries authenticate with Application Default Credentials (gcloud auth application-default login locally, an attached service account in production) and bypass security rules. Browser and mobile apps use the Firebase SDK (npm install firebase, modular firebase/firestore API) and are governed by security rules.

CRUD operations

from google.cloud import firestore

db = firestore.Client()

db.collection('users').document('user-001').set({
    'name': 'Alice Johnson',
    'email': '[email protected]',
    'role': 'admin',
    'created_at': firestore.SERVER_TIMESTAMP
})

# Add a document with auto-generated ID
ref = db.collection('orders').add({
    'user_id': 'user-001',
    'items': [
        {'name': 'Widget', 'qty': 2, 'price': 29.99},
        {'name': 'Gadget', 'qty': 1, 'price': 49.99}
    ],
    'total': 109.97,
    'status': 'pending',
    'created_at': firestore.SERVER_TIMESTAMP
})
print(f"Created order: {ref[1].id}")  # add() returns (update_time, ref)
doc = db.collection('users').document('user-001').get()
print(doc.to_dict() if doc.exists else 'missing')
db.collection('users').document('user-001').update({
    'role': 'superadmin',
    'updated_at': firestore.SERVER_TIMESTAMP
})

# Update nested fields with dotted paths
db.collection('users').document('user-001').update({'preferences.theme': 'dark'})
# Delete a document, or just one field
db.collection('users').document('user-001').delete()
db.collection('users').document('user-001').update({
    'temporary_field': firestore.DELETE_FIELD
})

Queries

from google.cloud.firestore_v1.base_query import FieldFilter

# Use filter=FieldFilter(...); the positional where(field, op, value) form emits a UserWarning
users_ref = db.collection('users')
admins = users_ref.where(filter=FieldFilter('role', '==', 'admin')).stream()

# Multiple conditions (equality + range + order needs a composite index, see Indexes)
recent_orders = db.collection('orders') \
    .where(filter=FieldFilter('status', '==', 'pending')) \
    .where(filter=FieldFilter('total', '>=', 50)) \
    .order_by('total', direction=firestore.Query.DESCENDING) \
    .limit(20) \
    .stream()

for order in recent_orders:
    print(f"{order.id}: ${order.to_dict()['total']}")
# Pagination with cursors
first_page = db.collection('orders') \
    .order_by('created_at', direction=firestore.Query.DESCENDING) \
    .limit(25) \
    .get()

last_doc = first_page[-1]
next_page = db.collection('orders') \
    .order_by('created_at', direction=firestore.Query.DESCENDING) \
    .start_after(last_doc) \
    .limit(25) \
    .get()
# Array and IN queries
db.collection('users').where(filter=FieldFilter('tags', 'array_contains', 'premium')).stream()

db.collection('orders').where(filter=FieldFilter('status', 'in', ['pending', 'processing'])).stream()

# Count without reading documents
count = db.collection('orders').where(filter=FieldFilter('status', '==', 'pending')).count(alias='n').get()
print(count[0][0].value)

Real-Time Listeners

// real-time-listener.js — server-side listener (Node library)
const { Firestore } = require('@google-cloud/firestore');
const db = new Firestore();

const unsubscribe = db.collection('orders').doc('order-001')
  .onSnapshot((doc) => {
    if (doc.exists) {
      console.log('Order updated:', doc.data());
    }
  });

const queryUnsubscribe = db.collection('orders')
  .where('status', '==', 'pending')
  .onSnapshot((snapshot) => {
    snapshot.docChanges().forEach((change) => {
      if (change.type === 'added') {
        console.log('New order:', change.doc.data());
      } else if (change.type === 'modified') {
        console.log('Updated order:', change.doc.data());
      } else if (change.type === 'removed') {
        console.log('Removed order:', change.doc.id);
      }
    });
  }
Полный SKILL.md на GitHub

Установить gcp-firestore в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл gcp-firestore?

Build real-time applications with Google Cloud Firestore. Model data with collections and documents, execute queries with composite indexes, set up real-time listeners for live updates, enable offline persistence, and write security rules for client-side access control.

Как установить скилл gcp-firestore?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл gcp-firestore запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить gcp-firestore с