Comparing version 0.2.6 to 0.2.7
@@ -16,2 +16,3 @@ "use strict"; | ||
const mongodb_1 = require("mongodb"); | ||
const _1 = require("./"); | ||
function setupMany(collection, documents, raw) { | ||
@@ -89,2 +90,11 @@ const data = raw || ['foo', 'bar', 'baz'].map(name => ({ name })); | ||
})); | ||
wrap_1.default('Collection.find().project()', (t) => __awaiter(this, void 0, void 0, function* () { | ||
const collection = connect_1.default().get(TestCollection_1.TestCollection); | ||
const documents = []; | ||
yield setupMany(collection, documents); | ||
const result = yield (yield collection.find({})).project({ foo: 1 }).fetch(); | ||
console.log(result); | ||
t.ok(result instanceof _1.PartialDocument, 'TestCollection.find({}).project().fetch() should return PartialDocument instead TestDocument'); | ||
return (yield collection.connection).disconnect(); | ||
})); | ||
wrap_1.default('Collection.insertOne()', (t) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -91,0 +101,0 @@ const collection = connect_1.default().get(TestCollection_1.TestCollection); |
@@ -14,2 +14,3 @@ /// <reference types="node" /> | ||
count(applySkipLimit?: boolean, options?: MongoDb.CursorCommentOptions): Promise<number>; | ||
project(fields: Object): this; | ||
limit(value: number): this; | ||
@@ -16,0 +17,0 @@ skip(value: number): this; |
@@ -11,2 +11,3 @@ "use strict"; | ||
const events_1 = require("events"); | ||
const _1 = require("./"); | ||
class Cursor extends events_1.EventEmitter { | ||
@@ -19,3 +20,3 @@ constructor(cursor, transform) { | ||
cursor.map(x => { | ||
return transform(x); | ||
return this.cast(x); | ||
}); | ||
@@ -35,2 +36,7 @@ } | ||
} | ||
project(fields) { | ||
this.cast = x => new _1.PartialDocument(x); | ||
this.cursor.project(fields); | ||
return this; | ||
} | ||
limit(value) { | ||
@@ -37,0 +43,0 @@ this.cursor.limit(value); |
@@ -47,2 +47,4 @@ /// <reference types="node" /> | ||
} | ||
export declare class PartialDocument extends SchemaDocument { | ||
} | ||
export declare class SchemaArray<T> extends Array<T> { | ||
@@ -49,0 +51,0 @@ protected readonly cast: (value: any) => T; |
@@ -196,2 +196,5 @@ "use strict"; | ||
exports.SchemaFragment = SchemaFragment; | ||
class PartialDocument extends SchemaDocument { | ||
} | ||
exports.PartialDocument = PartialDocument; | ||
class SchemaArray extends Array { | ||
@@ -198,0 +201,0 @@ constructor(values, cast) { |
{ | ||
"name": "mongot", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "A lightweight typed MongoDb library for TypeScript.", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127633
1932