https://github.com/renanviana/firebase4j
Plugin used to facilitate the use of Firebase services
https://github.com/renanviana/firebase4j
firebase firestore google-firebase google-storage google-storage-bucket java
Last synced: 4 months ago
JSON representation
Plugin used to facilitate the use of Firebase services
- Host: GitHub
- URL: https://github.com/renanviana/firebase4j
- Owner: renanviana
- License: mit
- Created: 2020-10-24T16:33:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T03:42:03.000Z (over 3 years ago)
- Last Synced: 2025-09-07T01:33:42.167Z (10 months ago)
- Topics: firebase, firestore, google-firebase, google-storage, google-storage-bucket, java
- Language: Java
- Homepage: https://firebase.google.com
- Size: 31.3 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
:fire::coffee: firebase4j
A plugin Java for Firebase applications
## :bulb: Installing
Add the dependency in your pom.xml
```xml
com.renz
firebase4j
1.0.1
```
Execute the command
```command
mvn install
```
## :running: Usage
Connect to Firebase before using services
```java
try (FirebaseConnection firebaseConn = new FirebaseConnection()) {
firebaseConn.connect("src/main/resources/YOUR_FIREBASE_ADMIN_SDK.json");
// Code block using services
} catch (Exception e) {
// exception handling
}
```
> To use Firestore, first you must configure your classes that will be persisted in the Database
Inherit the "Document" class in your collection model
```java
import com.renz.firebase4j.firestore.Document;
public class Person extends Document {
private String name;
private Integer age;
// getter's and setter's
}
```
Create a repository that inherits from the "FirestoreRepository" class and give the constructor the type of document class you would like to handle
```java
public class PersonRepository extends FirestoreRepository {
public PersonRepository() {
super(Person.class);
}
}
```
Now invoke the available methods
```java
try (FirebaseConnection firebaseConn = new FirebaseConnection()) {
firebaseConn.connect("src/main/resources/YOUR_FIREBASE_ADMIN_SDK.json");
PersonRepository personRep = new PersonRepository();
Person person = personRep.save(person); // create document
List results = personRep.findAll(); // consulting collections
personRep.delete(person.getId()); // search for a specific document by id
} catch (Exception e) {
// exception handling
}
```
Uploading files to Firebase Storage
```java
try (FirebaseConnection firebaseConn = new FirebaseConnection()) {
firebaseConn.connect("src/main/resources/YOUR_FIREBASE_ADMIN_SDK.json");
FirebaseStorage storage = new FirebaseStorage();
storage.uploadFile(new File("YOUR_FILE.extension"));
} catch (Exception e) {
// exception handling
}
```
## :computer: Want to help with the Project?
Create an "issue" and describe the features you would like in the application, or even bugs you found.
If you want to help with corrections, create your branch from `master` and open a Pull Request for me.
> :star: Could you favorite this repository? Just click on the star! Thank you very much!
## License
MIT