Skip to content

Commit

Permalink
updating data structure & firebase reference tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timbomckay committed Feb 12, 2022
1 parent ed16306 commit 9c23987
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 36 deletions.
14 changes: 14 additions & 0 deletions assets/ts/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getFirestore,
query,
where,
getDoc,
// getDocFromCache,
// doc,
} from 'firebase/firestore';
Expand Down Expand Up @@ -87,6 +88,19 @@ const foo = async () => {
items[doc.id] = doc.data();
});

const q2 = await getDocs(collection(db, 'campaigns'));
q2.forEach(async (doc) => {
// doc.data() is never undefined for query doc snapshots
const data = doc.data();

console.log('campaign', ' => ', data);

data.inventories.forEach(async (i) => {
const inventory = await getDoc(i);
console.log('inventory', inventory.data());
});
});

// async function wait(ms) {
// return new Promise((resolve) => {
// setTimeout(resolve, ms);
Expand Down
78 changes: 42 additions & 36 deletions data-structure.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,42 @@
"campaigns": {
"--campaign-uid-123--": {
"name": "The War of Storms",
"users": [ "--user-uid-123--" ],
"characters": [ "--character-uid-123--" ],
"users": [ "--user-reference-123--" ],
"characters": [ "--character-reference-123--" ],
"notes": [],
"timeline": [],
// campaign holds all items
"items": {
// bag of holding
"--item-uid-abc--": {
"notes": []
},
// unidentified item
"--item-uid-321--": {
"notes": [],
"identified": false
}
},
// TODO: items not on characters
"inventory": {}
"inventories": [
"--inventories-reference-1--",
"--inventories-reference-2--",
"--inventories-reference-3--"
],
"unidentified": [
"--item-reference-1--",
"--item-reference-2--",
"--item-reference-3--"
]
}
},
"characters": {
"--character-uid-123--": {
"name": "Tenebrae",
// sorting items
"inventory": {
// attuned items
"attuned": [
"--item-uid-321--",
"--item-uid-abc--"
],
// items held on person
"--character-uid-123--": [
"--item-uid-321--",
"--item-uid-abc--",
"--item-uid-xyz--"
],
// sorted items in bag of holding
"--item-uid-abc--": [
"--item-uid-321--",
"--item-uid-abc--",
"--item-uid-xyz--"
"campaign": "--campaign-reference--",
"attuned": [
"--item-reference-1--",
"--item-reference-2--",
"--item-reference-3--"
],
"inventory": [
"--inventories-reference-1--",
"--inventories-reference-2--",
"--inventories-reference-3--"
],
"notes": {
"items": [
{
"ref": "--any-reference-1--",
"entries": []
}
]
}
}
Expand All @@ -60,7 +55,19 @@
"description": "array | object",
"srd": "boolean",
"type": "string",
"tier": "string",
"tier": "string"
}
},
"inventories": {
"--inventory-uid-123": {
"name": "Equipment",
"ref": "--item-uid-321--",
"items": [
{
"ref": "--item-uid-321--",
"quantity": 3
}
]
}
},
"users": {
Expand All @@ -85,4 +92,3 @@
}
}
}

0 comments on commit 9c23987

Please sign in to comment.