type MongoDBSchemas = {
'db.books': Book;
'db.authors': Author;
}
const model: ClientBulkWriteModel<MongoDBSchemas> = {
namespace: 'db.books'
name: 'insertOne',
document: { title: 'Practical MongoDB Aggregations', authorName: 3 } // error `authorName` cannot be number
};
The type of the namespace field narrows other parts of the BulkWriteModel to use the correct schema for type assertions.namespace字段的类型缩小了BulkWriteModel的其他部分,以便为类型断言使用正确的架构。
A mapping of namespace strings to collections schemas.命名空间字符串到集合模式的映射。