- Build a Recipe Web App with Oracle Backend for Firebase
- Build a Recipe iOS App with Oracle Backend for Firebase
- Build a Recipe Android App with Oracle Backend for Firebase
- Oracle® Backend for Firebase (Fusabase) JavaScript SDK
- Oracle® Backend for Firebase (Fusabase) iOS SDK
- Oracle® Backend for Firebase (Fusabase) Android SDK
Web、iOS、Andorodのアプリケーションを作成するLiveLabsのコースは、概ね同じ章立てになっています。Lab 3と4は順番が入れ替わっていることがありますが、セキュリティ・ルールはLab 7で設定するため、シード・データのロードと認証の設定は、どちらが先でも後でも実施できます。
記事「Oracle APEXが構成済みのデータベースにOracle Backend for Firebaseを構成する」の作業に続けて実施することを想定しています。
セキュリティ・ルールを設定する
match /{document=**} { allow read, write: if true;}
match /recipes/{recipeId} {
allow read: if request.auth != null;
allow create: if request.auth != null && request.resource.data.ownerId == request.auth.uid;
allow update: if request.auth != null && request.auth.uid == resource.data.ownerId;
}
match /recipes/{recipeId}/ratings/{ratingId} {
allow read: if request.auth != null;
allow create: if request.auth != null;
}
match /recipes/{recipeId}/{fileName} {
allow read: if true;
allow create: if request.auth != null;
}
Webアプリを実装する
% mkdir fusabase-livelabs
% cd fusabase-livelabs
fusabase-livelabs %
git clone https://github.com/KillianLynch/fusabase-livelabs-web.git
fusabase-livelabs % git clone https://github.com/KillianLynch/fusabase-livelabs-web.git
Cloning into 'fusabase-livelabs-web'...
remote: Enumerating objects: 143, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 143 (delta 3), reused 1 (delta 0), pack-reused 134 (from 1)
Receiving objects: 100% (143/143), 377.72 MiB | 8.78 MiB/s, done.
Resolving deltas: 100% (12/12), done.
fusabase-livelabs %
fusabase-livelabs % ls fusabase-livelabs-web
checkpoints finished package.json README.md starter
fusabase-livelabs %
cd fusabase-livelabs-web
fusabase-livelabs % cd fusabase-livelabs-web
fusabase-livelabs-web %
Oracle Backend for Firebaseのコンソールより、Webアプリケーションを作成します。
fusabase-livelabs-web % npm install fusabase
added 2 packages, and audited 3 packages in 719ms
found 0 vulnerabilities
fusabase-livelabs-web % more package.json
{
"name": "fusabase-recipeshare-workshop",
"version": "0.1.0",
"private": true,
"type": "module",
"dependencies": {
"fusabase": "^26.2.0"
}
}
fusabase-livelabs-web %
// Paste only the key/value lines from the Fusabase console inside the object below.
// Do not copy `const fusabaseConfig =`, any SDK imports, or initialization boilerplate.
export const fusabaseConfig = {
// Replace these placeholder values with the lines you copied from Fusabase.
"schema": "testuser",
"app_name": "RecipeShareWeb",
"app_type": "WEB",
"app_id": "57524622CB221AFEE063020012AC22B0",
"objs_type": "dbfs",
"project_id": "573E3A97FC7320ADE063020012AC296D",
"storage_bucket": "dbfs_CXJHFAIIZAPLDEH",
"auth_type": "base",
"auth_id": "573E3A97FC7720ADE063020012AC296D",
"ords_host": "http://localhost:8181/ords/testuser/"
};
live-server --port=8000 --host=localhost
fusabase-livelabs-web % live-server --port=8000 --host=localhost
Serving "/Users/__________/Documents/fusabase-livelabs/fusabase-livelabs-web" at http://localhost:8000 (http://::1:8000)
Ready for changes
ディレクトリFinishedに作成されたWebアプリに接続します。
- Lab 3: Build the Public Recipe Experience, Task 3: Seed demo data and verify
- Lab 4: Authentication, Task 6: Verify authentication
- Lab 5: Write Recipe Data, Task 3: Create a recipe and add a rating
- Lab 6: Photo Upload, Task 3: Upload a photo and verify
- Lab 7: Security Rules, Task 5: Verify security rules block unauthorized edits
Backendを初期化する
match /{document=**} { allow read, write: if true;}
iOSアプリを実装する
iOSアプリのGitHubリポジトリをクローンします。
fusabase-livelabs % git clone https://github.com/KillianLynch/fusabase-livelabs-ios.git
Cloning into 'fusabase-livelabs-ios'...
remote: Enumerating objects: 160, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 160 (delta 5), reused 3 (delta 1), pack-reused 148 (from 1)
Receiving objects: 100% (160/160), 204.03 MiB | 6.85 MiB/s, done.
Resolving deltas: 100% (18/18), done.
fusabase-livelabs %
fusabase-livelabs % ls fusabase-livelabs-ios
checkpoints finished README.md starter
fusabase-livelabs %
open RecipeShare.xcodeproj
fusabase-livelabs % cd fusabase-livelabs-ios/finished
finished % open RecipeShare.xcodeproj
finished %
Oracle Backend for Firebaseのコンソールより、iOSアプリケーションを作成します。
let seeds: [[String: Any]] = [
let seeds: [[String: Any?]] = [
var data: [String: Any] = [
var data: [String: Any?] = [
let author = authService.user?.email ?? "anonymous"
// 1. Write the rating into the subcollection.
var ratingData: [String: Any?] = [
"author": author,
"rating": rating,
"createdAt": Date().timeIntervalSince1970 * 1000.0
]
if let comment, !comment.isEmpty {
ratingData["comment"] = comment
}
let recipeRef = db.collection("recipes").document(recipeId)
_ = try await recipeRef.collection("ratings").addDocument(data: ratingData)
// 2. Read parent recipe to recompute aggregates.
let snap = try await recipeRef.getDocument()
let data = snap.data() ?? [:]
let oldAvg = (data["averageRating"] as? Double) ?? 0
let oldCount = (data["ratingCount"] as? Int) ?? 0
let newCount = oldCount + 1
let newAvg = (oldAvg * Double(oldCount) + Double(rating)) / Double(newCount)
// 3. Write the new aggregates back to the parent.
try await recipeRef.updateData([
"averageRating": newAvg,
"ratingCount": newCount
])
// Refresh the published list so the updated rating summary appears.
try await loadRecipes(category: nil)
- Lab 3: Authentication, Task 6: Create an app user
- Lab 4: Read Recipe Data, Task 3: Seed demo data and verify
- Lab 5: Write Recipe Data, Task 4: Create a recipe and add a rating
- Lab 6: Photo Upload, Task 3: Make sure the Simulator has a photo to pick
- Lab 6: Photo Upload, Task 4: Upload a photo and verify
- Lab 7: Security Rules, Task 5: Verify security rules block unauthorized edits
Androidアプリを実装する
git clone https://github.com/KillianLynch/fusabase-livelabs-android.git
fusabase-livelabs % git clone https://github.com/KillianLynch/fusabase-livelabs-android.git
Cloning into 'fusabase-livelabs-android'...
remote: Enumerating objects: 205, done.
remote: Counting objects: 100% (205/205), done.
remote: Compressing objects: 100% (166/166), done.
remote: Total 205 (delta 24), reused 197 (delta 22), pack-reused 0 (from 0)
Receiving objects: 100% (205/205), 18.10 MiB | 6.26 MiB/s, done.
Resolving deltas: 100% (24/24), done.
fusabase-livelabs %
fusabase-livelabs % ls fusabase-livelabs-android
checkpoints finished README.md starter
fusabase-livelabs %
App Nicknameはcom.oracle.fusabase.recipeshareとします。
Register Appをクリックします。
- Lab 3: Authentication, Task 6: Run and verify
- Lab 4: Read Recipe Data, Task 6: Run and verify
- Lab 5: Write Recipe Data, Task 3: Run and verify
- Lab 6: Photo Upload, Task 3: Run and verify
- Lab 7: Security Rules, Task 5: Verify security rules block unauthorized edits




































































