New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

ts-mongoose

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-mongoose - npm Package Compare versions

Comparing version

to
0.0.12

@@ -1,2 +0,2 @@

import { Types } from 'mongoose';
import { Types, Model } from 'mongoose';
export declare type Extract<T> = T extends {

@@ -15,2 +15,3 @@ definition: infer U;

export declare type Populate<T, P> = T extends Array<infer U> ? P extends keyof U ? Array<PopulateItem<U, P>> : T : P extends keyof T ? PopulateItem<T, P> : T;
export declare type ExtractDoc<T> = T extends Model<infer U> ? U : never;
export {};
{
"name": "ts-mongoose",
"version": "0.0.11",
"version": "0.0.12",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -160,2 +160,28 @@ # ts-mongoose

## Extracting Document type
Use `ExtractDoc` to extract generated type by `createSchema`.
Example:
```ts
import { createSchema, Type, typedModel, ExtractDoc } from 'ts-mongoose';
export const UserSchema = createSchema({
email: Type.string(),
username: Type.string(),
isBlocked: Type.boolean(),
});
export const User = typedModel('User', UserSchema);
export type UserDoc = ExtractDoc<typeof User>;
// example function
async function blockUser(user: UserDoc) {
user.isBlocked = true;
await user.save();
}
```
## Refs

@@ -162,0 +188,0 @@ Refs and populations are supported.

@@ -1,2 +0,2 @@

import { Types } from 'mongoose';
import { Types, Model } from 'mongoose';
export declare type Extract<T> = T extends {

@@ -15,2 +15,3 @@ definition: infer U;

export declare type Populate<T, P> = T extends Array<infer U> ? P extends keyof U ? Array<PopulateItem<U, P>> : T : P extends keyof T ? PopulateItem<T, P> : T;
export declare type ExtractDoc<T> = T extends Model<infer U> ? U : never;
export {};