Skip to content

Commit

Permalink
Merge pull request #48 from tylim88/new-features
Browse files Browse the repository at this point in the history
housekeeping
  • Loading branch information
tylim88 authored Apr 30, 2022
2 parents 2ee8f4b + 4fc44b9 commit ead5278
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 14 deletions.
8 changes: 7 additions & 1 deletion .opensource/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

"pages": [],

"related": ["tylim88/Firelordrn", "tylim88/Firelord"],
"related": [
"tylim88/Firelordrn",
"tylim88/Firelord",
"tylim88/FireLaw",
"tylim88/FireCall",
"tylim88/FireCaller"
],

"tabs": []
}
7 changes: 5 additions & 2 deletions codeForDoc/src/batch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { example } from './init'
import { example, db } from './init'
import { writeBatch, serverTimestamp } from 'firelordjs'

const batch = writeBatch()
const batch = writeBatch(db)
// OR
const batch_Alt = writeBatch()

export const dummy = async () => {
batch.set(example.doc('hij'), {
a: 6,
Expand Down
31 changes: 24 additions & 7 deletions codeForDoc/src/documentIdFirelord.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import { MetaTypeCreator, getFirelord, query, where } from 'firelordjs'
import { MetaTypeCreator, getFirelord } from 'firelordjs'

const firelord = getFirelord()

type abc = MetaTypeCreator<
type Parent = MetaTypeCreator<
{
a: { b: number; c: number }
d: number
a: 1
},
'abc',
'a',
string
>
const firelordParent = getFirelord<Parent>()
const ParentCollectionGroupQuery = firelordParent('a').collectionGroup()

type Child = MetaTypeCreator<
{
a: 1
},
'b',
string,
Parent
>
const firelordChild = getFirelord<Child>()

const ChildCollectionGroupQuery = firelordChild(
'a/putAnyStringHere/b'
).collectionGroup()

const a = [1, 2, 3].forEach(i => {
exports[i]
})
12 changes: 12 additions & 0 deletions codeForDoc/src/groupCollectionQueryFirelord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { MetaTypeCreator, getFirelord, query, where } from 'firelordjs'

const firelord = getFirelord()

type abc = MetaTypeCreator<
{
a: { b: number; c: number }
d: number
},
'abc',
string
>
9 changes: 8 additions & 1 deletion codeForDoc/src/init.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { getFirelord } from 'firelordjs'
import { initializeApp } from 'firebase/app'
import { Example } from './dataType'
import { getFirestore } from 'firebase/firestore'

initializeApp({
apiKey: '### FIREBASE API KEY ###',
authDomain: '### FIREBASE AUTH DOMAIN ###',
projectId: '### CLOUD FIRESTORE PROJECT ID ###',
})

export const example = getFirelord<Example>()('SomeCollectionName')
export const db = getFirestore()

const firelordExample = getFirelord<Example>(db)
// OR
const firelordExample_Alt = getFirelord<Example>()

export const example = firelordExample('SomeCollectionName')
6 changes: 5 additions & 1 deletion codeForDoc/src/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { example } from './init'
import { example, db } from './init'
import {
runTransaction,
serverTimestamp,
Expand All @@ -8,6 +8,10 @@ import {

export const dummy = async () => {
try {
await runTransaction(db, async transaction => {
// ...
})
// OR you can skip 'db'
await runTransaction(async transaction => {
await transaction.get(example.doc('lmn')).then(docSnapshot => {
const data = docSnapshot.data()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firelordjs",
"version": "1.1.17",
"version": "1.1.18",
"description": "🔥 Extremely High Precision Typescript Wrapper for Firestore Web, Providing Unparalleled Type Safe and Dev Experience",
"source": "src/index.ts",
"main": "dist/src/index.js",
Expand Down
2 changes: 1 addition & 1 deletion scripts/installLatest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import pkg from '../package.json'
import shell from 'shelljs'

// https://stackoverflow.com/questions/38032047/how-to-execute-npm-run-command-programmatically
// to make sure it always install the latest exact version because apparently `latest` is not working in package.json with just published package
// this code is for newly published code testing because @latest apparently not alway able to target newly published package
shell.exec(`npm --prefix codeForDoc i ${pkg.name}@${pkg.version}`)

0 comments on commit ead5278

Please sign in to comment.