Question
Is there a way to save enum into the mongoDB? I want to save something like:
public enum SnapshotType {
EVENT,
MEMORY
}
La solution
I assume you mean saving an enum value into a collection.
Basically, you just add it into your entity model, like so:
@Document(collection = "MyEntity ")
public class MyEntity {
public SnapshotType snapshotType;
}
It will store it as a string in mongo, and automagically convert when you read it out.
Autres conseils
Just save the result. There are no schemas in mongo.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow