Example usage for com.mongodb MongoNamespace getCollectionName

List of usage examples for com.mongodb MongoNamespace getCollectionName

Introduction

In this page you can find the example usage for com.mongodb MongoNamespace getCollectionName.

Prototype

@BsonProperty("coll")
public String getCollectionName() 

Source Link

Document

Gets the collection name.

Usage

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());
}