npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@xeaone/database

v3.6.4

Published

X-Database A Deno database client for Google Cloud Firestore.

Downloads

20

Readme

deno module deno compatibility GitHub

X-Database

A Deno database client for Google Cloud Firestore.

Example

import Database from 'https://deno.land/x/xdatabase/src/mod.ts';

const database = new Database();

database.credential('application');
database.project('google-cloud-project-id');

const id = crypto.randomUUID();

const user = await database.create('user', {
    id,
    age: 20,
    phone: null,
    active: true,
    lastName: 'bar',
    firstName: 'foo',
}).identifier(id).end();

console.log(user);

const users = await database
    .search('user')
    .equal({ firstName: 'foo' })
    .limit(10).end();

console.log(user);

Auth

It is recommended to use the 'application' String option this will use the Application Default Credential and will fallback to trying to use the Google Cloud service instance account credentials. You can initialize the Application Default Credential using this command gcloud auth application-default login. Alternatively you can pass a ServiceAccountCredentials key Object, ApplicationDefaultCredentials key Object, or the 'meta' String. The option to manually use 'meta' is nice for production because the only deno permission you should need is network.

  • 'meta'
    • http://metadata.google.internal
  • 'application' Deno permissions read
    • Windows: %APPDATA%\gcloud\application_default_credentials.json
    • Linux/Mac: $HOME/.config/gcloud/application_default_credentials.json

API

id(id: string): this

The database id default is (default)

project(project: string): this

The GCP project name.

credential(credential: 'meta' | 'application' | ServiceAccountCredentials | ApplicationDefaultCredentials): this

  • meta
  • application
  • ServiceAccountCredentials
  • ApplicationDefaultCredentials

search(collection: string)

const users = await database.search('user').equal({ id: '1' }).end();

view(collection: string)

const user = await database.view('user').equal({ id: '1' }).end();

remove(collection: string)

const user = await database.remove('user').identifier('1').end();

create(collection: string, data: Data)

const user = await database.create('user', {
    id: '1',
    name: 'foo bar',
    age: 42,
}).identifier('1').end();

update(collection: string, data: Data)

const user = await database.update('user', { age: 69 }).equal({ id: '1' })
    .end();

commit(collection: string, data: Data)

const user = await database.commit('user').equal({ id: '1' }).increment({
    age: 1,
}).end();

Options

// All Except Search:
identifier(string)

// All Except Set: Property starts with filter
startsWith(Array<string>)

// All Except Set:
in(Array<string>)

// All Except Set:
notIn(Array<string>)

// All Except Set: default
equal(Array<string>)

// All Except Set:
notEqual(Array<string>)

// All Except Set:
lessThan(Array<string>)

// All Except Set:
lessThanOrEqual(Array<string>)

// All Except Set:
arrayContains(Array<string>)

// All Except Set:
arrayContainsAny(Array<string>)

// All Except Set:
greaterThan(Array<string>;

// All Except Set:
greaterThanOrEqual(Array<string>)

// Search: orders results by property name/s
ascending(Array<string>)
descending(Array<string>)

// Search:
// Firestore: https://firebase.google.com/docs/firestore/reference/rest/v1/StructuredQuery#FIELDS.start_at
start(Array<Record<string, Data>>)

// Search:
// Firestore: https://firebase.google.com/docs/firestore/reference/rest/v1/StructuredQuery#FIELDS.end_at
end(Array<Record<string, Data>>)

// Search: The maximum number of results to return.
// Firestore: https://firebase.google.com/docs/firestore/reference/rest/v1/StructuredQuery#FIELDS.limit
limit(number)

// Search: The number of results to skip.
// Firestore: https://firebase.google.com/docs/firestore/reference/rest/v1/StructuredQuery#FIELDS.offset
offset(number)

// Set: property name/s to increment
// https://firebase.google.com/docs/firestore/reference/rest/v1/Write#FieldTransform.FIELDS.increment
increment(Array<string>)

// Set: property name/s to append missing elements
// Firestore: https://firebase.google.com/docs/firestore/reference/rest/v1/Write#FieldTransform.FIELDS.append_missing_elements
append(Array<string>)