Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alperkurtul/spring-boot-starter-firebase-realtime-database
RELEASED version -- An Easy Way to Access Firebase Realtime Database in Spring Boot
https://github.com/alperkurtul/spring-boot-starter-firebase-realtime-database
firebase firebase-realtime-database spring-boot springboot
Last synced: about 2 months ago
JSON representation
RELEASED version -- An Easy Way to Access Firebase Realtime Database in Spring Boot
- Host: GitHub
- URL: https://github.com/alperkurtul/spring-boot-starter-firebase-realtime-database
- Owner: alperkurtul
- License: mit
- Created: 2019-10-29T21:25:20.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-14T17:58:43.000Z (over 1 year ago)
- Last Synced: 2024-10-06T06:04:35.615Z (3 months ago)
- Topics: firebase, firebase-realtime-database, spring-boot, springboot
- Language: Java
- Homepage:
- Size: 175 KB
- Stars: 22
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# An Easy Way to Access `Firebase Realtime Database` in Spring Boot
This project gives you the ability to access to `Firebase Realtime Database`. To achieve this, you just have to add some basic annotations and define a generic repository in your Spring Boot application. These are the list of methods you can use in this release(1.0.5):- save (@Deprecated in 1.0.5.RELEASE)
- saveWithRandomId (added in 1.0.5.RELEASE)
- saveWithSpecificId (added in 1.0.5.RELEASE)
- read
- update
- delete## How to Apply
### Configuration
Add this property in your `application.properties`.
```properties
firebase-realtime-database.database-url=[firebase realtime database url]
```### Dependencies
Primarily, you have to add `spring-boot-starter-web` dependency in your Spring Boot application.
```xmlorg.springframework.boot
spring-boot-starter-web```
Then, you have to also add this dependency in your `pom.xml`.
```xmlcom.github.alperkurtul
spring-boot-starter-firebase-realtime-database
1.0.5.RELEASE```
### and How to Use
1) create a class for your Firebase Realtime Database `Document`
2) annotate this class as `@FirebaseDocumentPath` and specify a path for your realtime database
3) create a `String` property for your `authentication idToken` and annotate it as `@FirebaseUserAuthKey`
- for a valid `authentication idToken`, use `spring-boot-starter-firebase-user-authentication`.
4) create a property for the ID and annotate it with `@FirebaseDocumentId````java
@FirebaseDocumentPath("/product")
public class Product {@FirebaseUserAuthKey
private String authKey;
@FirebaseDocumentId
private String firebaseId;
private String id;
private String name;
private BigDecimal price;}
```Then create a Repository class. This class must extend the `FirebaseRealtimeDbRepoServiceImpl` class.
```java
@Repository
public class ProductRepository extends FirebaseRealtimeDbRepoServiceImpl {
}
```At last, put `@EnableFirebaseRealtimeDatabase` just next to `@SpringBootApplication` in your main class of Spring Boot application.
```java
@EnableFirebaseRealtimeDatabase
@SpringBootApplication
public class DemoApplication {public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}}
```### Demo
Here is a demo that I made for you. `Demo`### Releases
- 1.0.5.RELEASE (2019-11-27)
- **BugFix :** Annotated fields (@FirebaseUserAuthKey and @FirebaseDocumentId) also were being saved to Firebase Database. It is fixed.
- `save` method `@Deprecated`
- Instead of `save` method, `saveWithRandomId` method was added.
- `saveWithSpecificId` method wad added as a new feature. By using this method, you can set specific FirebaseId of your record.
## Next
I hope, I will be able to continue to add new features in the next. Don't be shy to send your advice to me.
Take care...