List of usage examples for com.mongodb MongoNamespace getCollectionName
@BsonProperty("coll") public String getCollectionName()
From source file:com.exorath.simpleapi.impl.database.DBDataImpl.java
License:Apache License
private void setup(MongoNamespace namespace, Document bson) { this.namespace = namespace; if (bson == null) { this.bson = new DBDataDocument(new Document("_id", id.toString())); SimpleAPIImpl.getDatabaseManager().withCollectionConsumer(namespace.getDatabaseName(), namespace.getCollectionName(), c -> c.insertOne(new Document(this.bson))); } else/*from w w w . j av a 2 s . com*/ this.bson = new DBDataDocument(bson); id = this.bson.getString("_id"); loaded = true; }
From source file:org.springframework.data.mongodb.core.messaging.ChangeStreamTask.java
License:Apache License
@Override protected Message<ChangeStreamDocument<Document>, Object> createMessage(ChangeStreamDocument<Document> source, Class<Object> targetType, RequestOptions options) { // namespace might be null for eg. OperationType.INVALIDATE MongoNamespace namespace = Optional.ofNullable(source.getNamespace()) .orElse(new MongoNamespace("unknown", options.getCollectionName())); return new ChangeStreamEventMessage<>(new ChangeStreamEvent<>(source, targetType, mongoConverter), MessageProperties.builder().databaseName(namespace.getDatabaseName()) .collectionName(namespace.getCollectionName()).build()); }