mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
Add mongoose-auto-increment.d.ts
This commit is contained in:
20
mongoose-auto-increment/mongoose-auto-increment-tests.ts
Normal file
20
mongoose-auto-increment/mongoose-auto-increment-tests.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/// <reference path="../mongoose/mongoose.d.ts" />
|
||||
/// <reference path="./mongoose-auto-increment.d.ts" />
|
||||
|
||||
import * as autoIncrement from 'mongoose-auto-increment';
|
||||
import * as mongoose from 'mongoose';
|
||||
import { Schema } from 'mongoose';
|
||||
|
||||
var connection = mongoose.createConnection("mongodb://localhost/myDatabase");
|
||||
|
||||
autoIncrement.initialize(connection);
|
||||
|
||||
var bookSchema = new Schema({
|
||||
author: { type: Schema.Types.ObjectId, ref: 'Author' },
|
||||
title: String,
|
||||
genre: String,
|
||||
publishDate: Date
|
||||
});
|
||||
|
||||
bookSchema.plugin(autoIncrement.plugin, 'Book');
|
||||
var Book = connection.model('Book', bookSchema);
|
||||
20
mongoose-auto-increment/mongoose-auto-increment.d.ts
vendored
Normal file
20
mongoose-auto-increment/mongoose-auto-increment.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Type definitions for mongoose-auto-increment 5.0.1
|
||||
// Project: https://github.com/codetunnel/mongoose-auto-increment
|
||||
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../mongoose/mongoose.d.ts" />
|
||||
|
||||
declare module 'mongoose-auto-increment' {
|
||||
import { Connection, Schema, Mongoose } from 'mongoose';
|
||||
|
||||
/**
|
||||
* Initialize plugin by creating counter collection in database.
|
||||
*/
|
||||
function initialize(connection: Connection): void;
|
||||
|
||||
/**
|
||||
* The function to use when invoking the plugin on a custom schema.
|
||||
*/
|
||||
function plugin(schema: Schema, options: Object): void;
|
||||
}
|
||||
Reference in New Issue
Block a user