Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongot

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongot - npm Package Compare versions

Comparing version 0.2.7 to 0.2.8

9

build/collection.spec.js

@@ -36,3 +36,3 @@ "use strict";

for (let i = 0; i < 100; i++) {
foos.push({ foo: "foo" + i.toString() });
foos.push({ name: "foo" + i.toString() });
}

@@ -93,6 +93,7 @@ yield setupMany(collection, documents, foos);

const documents = [];
yield setupMany(collection, documents);
const result = yield (yield collection.find({})).project({ foo: 1 }).fetch();
console.log(result);
const number = Math.random();
yield setupMany(collection, documents, [{ name: 'foo', number, version: 1 }]);
const result = yield (yield collection.find({})).project({ name: 1, number: 1 }).fetch();
t.ok(result instanceof _1.PartialDocument, 'TestCollection.find({}).project().fetch() should return PartialDocument instead TestDocument');
t.same(result.toObject(), { name: 'foo', number, _id: result._id.toString() }, 'PartialDocument should have custom fields');
return (yield collection.connection).disconnect();

@@ -99,0 +100,0 @@ }));

@@ -14,3 +14,3 @@ /// <reference types="node" />

count(applySkipLimit?: boolean, options?: MongoDb.CursorCommentOptions): Promise<number>;
project(fields: Object): this;
project(fields: Object | string): this;
limit(value: number): this;

@@ -17,0 +17,0 @@ skip(value: number): this;

@@ -35,4 +35,9 @@ "use strict";

project(fields) {
this.cast = x => new _1.PartialDocument(x);
this.cursor.project(fields);
this.cast = x => _1.PartialDocument.factory(x);
if (typeof fields === 'string') {
this.cursor.project(Object.assign({}, ...fields.split(/[\s,]*/).map(x => ({ [x]: 1 }))));
}
else {
this.cursor.project(fields);
}
return this;

@@ -39,0 +44,0 @@ }

@@ -22,7 +22,3 @@ /// <reference types="node" />

static factory<T extends SchemaMetadata>(document?: Object): T;
protected getMetadata(): Map<string | symbol, {
type?: any;
proto?: any;
required?: boolean;
}>;
protected getMetadata(): any;
protected getPropertyMetadata(property: any): {

@@ -29,0 +25,0 @@ type?: any;

@@ -140,3 +140,5 @@ "use strict";

const merge = Object.assign({}, this, document);
this.getMetadata().forEach(({ type, proto }, key) => {
const metadata = this.getMetadata();
assert_1.ok(!!metadata, `Metadata does not defined for ${this.constructor.name}`);
metadata.forEach(({ type, proto }, key) => {
const storageKey = Symbol(key);

@@ -166,2 +168,6 @@ Object.defineProperty(this, storageKey, { value: undefined, writable: true, configurable: false });

getMetadata() {
if (this instanceof PartialDocument) {
const obj = Object.keys(this).filter(x => x !== '_id').map(x => ([x, { type: Object, proto: Object }]));
return new Map([...obj]);
}
return store_1.MetadataStore.getSchemaMetadata((this.constructor));

@@ -168,0 +174,0 @@ }

{
"name": "mongot",
"version": "0.2.7",
"version": "0.2.8",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc