mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
18 lines
503 B
TypeScript
18 lines
503 B
TypeScript
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);
|