Tal Barda
Tal Barda

Reputation: 4287

Firebase @Exclude annotation for both Firestore and Realtime Database?

I have some marked fields with the @Exclude annotation, in order to keep them away from the database:

@IgnoreExtraProperties
public class Model {
    @Exclude private String id;
}

My problem is that this annotation is valid for only one database at a time.

I can improt this interface from the Firestore library like this:

import com.google.firebase.firestore.Exclude;

and I can import it from the Firebase Database library:

import com.google.firebase.database.Exclude;

The fact that I can't import both of them at the same time is a problem for me because I'd like to have the same object with the same excluded fields from both of the databases.

Is it possible to exclude fields in an object from both of the databases?

Upvotes: 5

Views: 1459

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317712

Any time you need to use two Java classes in the same source file, you need to refer to one or both of them by their fully qualified name. For example:

@Exclude  // from Firestore
@com.google.firebase.database.Exclude  // from Realtime Database
int thing;

Upvotes: 5

Related Questions