Add mongoose-auto-increment.d.ts

This commit is contained in:
Aya Morisawa
2015-11-22 13:45:55 +09:00
parent b937e64fc9
commit dd8d66353d
2 changed files with 40 additions and 0 deletions

View 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);

View 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;
}