{"id":15107707,"url":"https://github.com/psvensson/firebase-st","last_synced_at":"2025-10-23T02:31:28.585Z","repository":{"id":52798377,"uuid":"263976714","full_name":"psvensson/firebase-st","owner":"psvensson","description":"A simple Smalltalk layer on top of the Google Firestore REST API, since no working gRPC/Protobuf libraries exists yet for Smalltalk","archived":false,"fork":false,"pushed_at":"2021-11-23T06:13:51.000Z","size":74,"stargazers_count":10,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T17:11:17.273Z","etag":null,"topics":["firebase","pharo","pharo-smalltalk","smalltalk"],"latest_commit_sha":null,"homepage":null,"language":"Smalltalk","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/psvensson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-14T17:08:35.000Z","updated_at":"2024-07-07T18:34:10.000Z","dependencies_parsed_at":"2022-08-23T04:01:38.178Z","dependency_job_id":null,"html_url":"https://github.com/psvensson/firebase-st","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psvensson%2Ffirebase-st","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psvensson%2Ffirebase-st/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psvensson%2Ffirebase-st/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psvensson%2Ffirebase-st/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psvensson","download_url":"https://codeload.github.com/psvensson/firebase-st/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237769067,"owners_count":19363250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["firebase","pharo","pharo-smalltalk","smalltalk"],"created_at":"2024-09-25T21:41:07.548Z","updated_at":"2025-10-23T02:31:28.249Z","avatar_url":"https://github.com/psvensson.png","language":"Smalltalk","funding_links":[],"categories":[],"sub_categories":[],"readme":"# firebase-st\nA simple Smalltalk layer on top of the Google Firebase REST API, since no working gRPC/Protobuf libraries exists yet for Smalltalk.\n\n# Installation\n\n```Smalltalk\nMetacello new\n    repository: 'github://psvensson/firebase-st:master';\n    baseline: 'Firebase';\n    load\n```\n\n# Usage\n\nYou need to generate a service account credential file in JSON format, which can be done either from the Firebase project settings page or from the Google Cloud console; https://cloud.google.com/iam/docs/creating-managing-service-account-keys\n\n```Smalltalk\ncertificateString := 'opencobalt-firebase-adminsdk.json' asFileReference readStream contents.\n\n\"push put and patch uses dictionaries as objects\"\nobj := Dictionary new.\nobj at: #abc put: 'foobar'.\n\n\"queries are also objects, and which keys can be any of; startAt endAt limitToFirst limitToLast equalTo orderBy)\"\nquery := Dictionary new.\nquery at: #orderBy put: '\"$key\"'.\n\nfirebase := Firebase new: certificateString .\nrtdb := FirebaseRtdb new: firebase.\n(rtdb putPath: '/foo/bar' obj: obj ) onSuccessDo: [ :res | Transcript show:'put result=',res asString;cr ].\n(rtdb get: '/foo' query: query ) onSuccessDo: [ :res | Transcript show:'put result=',res asString;cr ].\n```\n\n# Methods for rtdb\n\nRtdb is the original firestore real-time database. All data for a project resides in one large JSON structure, so be careful what you get or query, as you might get back quite a lot of data. Queries can only be made at one property at a time, which limits the use a bit.\n\n* getPath: path \"get data under path\"\n* deletePath: path \"delete data from path\"\n* get: path \"get data at path but not under\"\n* query: query \"see example above\"\n* putPath: path obj: obj \"add data under path\"\n* pushPath: path obj: obj \"add data to array on object path\"\n* patchPath: path obj: obj \"update data on path\"\n\nputPath adds new object to a path, pushPath pushes a new member of an array or an object of an existing path, pachPath replaces an existing path's proeprties with those proivded in the obj.\n\n# Firestore Usage\n\nFirestore is the new firebase datastore with a more traditional noSQL way of organizing data. You create collections (tables) where you store documents (which can contain sub-collections). You can query on multiple properties and if an index needs to be created for the query, you will get a handy url back in an error message telling where to go to add one.\n\n```Smalltalk\n|certificateString firebase firestore data data2 data3 query res|\ndata := Dictionary new.\ndata at: 'hej' put: 'svejs2'.\ndata at: 'foo' put: #(a b c).\ndata2 := Dictionary new.\ndata2 at: #x put: #y.\ndata3 := Dictionary new.\ndata3 at: #deep put: #stuff.\ndata at: #z put: data3.\ncertificateString := 'service_account.json' asFileReference readStream contents.\n\nfirebase := Firebase new: certificateString .\nfirestore := Firestore new: firebase.\n\nres := firestore create: 'bar' id: 'whoop2' document: data.\nres onSuccessDo: [ :s | Transcript show:'Success: ',s asString;cr ].\nres onFailureDo: [ :e | Transcript show:'Failure: ',e asString;cr ].\nres\n```\n\nThe above code in a playground will create a new collection named 'bar' (if it doesn't exist already) and adds a nontrivial JSON document with id 'whoop2'.\n\n```Smalltalk\n|certificateString firebase firestore data query res|\ncertificateString := 'service_account.json' asFileReference readStream contents.\n\nfirebase := Firebase new: certificateString .\nfirestore := Firestore new: firebase.\n\nquery := Dictionary new.\nquery \n\tat: #from put: #bar\n\t;at: #select put: #(hej)\t\n\t;at: #where put: #('hej.EQUAL.svejs')\n\t;at: #direction put: 'ASCENDING'.\n\nres := firestore runQuery: query.\nres onSuccessDo: [ :s | Transcript show:'Success: ',s asString;cr. ].\nres onFailureDo: [ :e | Transcript show:'Failure: ',e asString;cr ].\nres\n```\n\nThis is a complex query with one 'where' clause which also filte rout just the proeprties you want to seee using 'select'.\nA list of possible where operators can be found here; https://firebase.google.com/docs/firestore/reference/rest/v1beta1/StructuredQuery#FieldFilter\n\n```Smalltalk\nquery := Dictionary new.\nquery \n\tat: #from put: #bar\n\t;at: #offset put: 3\t\n\t;at: #direction put: 'ASCENDING'.\n\nres := firestore runQuery: query.\nres onSuccessDo: [ :s | Transcript show:'Success: ',s asString;cr. s inspect].\nres onFailureDo: [ :e | Transcript show:'Failure: ',e asString;cr ].\nres\n```\n\nAnd the above is a simple query which uses offset, to enable a simple form of pagination.\n\n# Methods for Firestore\n\n* list: path pageSize: pageSize pageToken: pageToken orderBy: orderBy  \"All can be nil except for 'path'\"\n* create: path id:id document: document \"path is the colelction name and id (if not nil) is the desired id. If nil, an id will be generated\"\n* get: path \"Get the document on the path, like 'bar/whoop2'\"\n* patch: path document: document \"Update an existing document\"\n* runQuery: query \"Query properties can be any of from, select, where, direction, limit, offset and orderBy\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsvensson%2Ffirebase-st","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsvensson%2Ffirebase-st","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsvensson%2Ffirebase-st/lists"}