mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
reverts to interfaces
This commit is contained in:
+32
-20
@@ -52,7 +52,7 @@ mongoose.model('Actor', new mongoose.Schema({
|
||||
}), 'collectionName', true).find({});
|
||||
mongoose.model('Actor').find({});
|
||||
mongoose.modelNames()[0].toLowerCase();
|
||||
new (new mongoose.Mongoose()).Mongoose().connect('');
|
||||
new (new mongoose.Mongoose(9, 8, 7)).Mongoose(1, 2, 3).connect('');
|
||||
mongoose.plugin(cb, {}).connect('');
|
||||
mongoose.set('test', 'value');
|
||||
mongoose.set('debug', function(collectionName: any, methodName: any, arg1: any, arg2: any) {});
|
||||
@@ -136,7 +136,6 @@ conn1.model('myModel', new mongoose.Schema({}), 'myCol').find();
|
||||
interface IStatics {
|
||||
staticMethod1: (a: number) => string;
|
||||
}
|
||||
conn1.model<{}, IStatics>('').staticMethod1;
|
||||
conn1.modelNames()[0].toLowerCase();
|
||||
conn1.config.hasOwnProperty('');
|
||||
conn1.db.bufferMaxEntries;
|
||||
@@ -350,7 +349,7 @@ new mongoose.Schema({
|
||||
* section document.js
|
||||
* http://mongoosejs.com/docs/api.html#document-js
|
||||
*/
|
||||
var doc: mongoose.Document;
|
||||
var doc: mongoose.MongooseDocument;
|
||||
doc.$isDefault('path').valueOf();
|
||||
doc.depopulate('path');
|
||||
doc.equals(doc).valueOf();
|
||||
@@ -465,7 +464,7 @@ mongooseArray.length;
|
||||
* http://mongoosejs.com/docs/api.html#types-documentarray-js
|
||||
*/
|
||||
// The constructor is private api, but we'll use it to test
|
||||
var documentArray: mongoose.Types.DocumentArray<mongoose.Document> =
|
||||
var documentArray: mongoose.Types.DocumentArray<mongoose.MongooseDocument> =
|
||||
new mongoose.Types.DocumentArray();
|
||||
documentArray.create({}).errors;
|
||||
documentArray.id(new Buffer('hi'));
|
||||
@@ -500,7 +499,7 @@ var objectId: mongoose.Types.ObjectId = mongoose.Types.ObjectId.createFromHexStr
|
||||
objectId = new mongoose.Types.ObjectId(12345);
|
||||
objectId.getTimestamp();
|
||||
/* practical examples */
|
||||
export interface IManagerSchema extends mongoose.Document {
|
||||
export interface IManagerSchema extends mongoose.MongooseDocument {
|
||||
user: mongoose.Schema.Types.ObjectId;
|
||||
}
|
||||
export var ManagerSchema = new mongoose.Schema({
|
||||
@@ -530,7 +529,7 @@ embeddedDocument.execPopulate();
|
||||
* section query.js
|
||||
* http://mongoosejs.com/docs/api.html#query-js
|
||||
*/
|
||||
var query: mongoose.Query<mongoose.Document[]>;
|
||||
var query: mongoose.Query<mongoose.MongooseDocument[]>;
|
||||
query.$where('').$where(cb);
|
||||
query.all(99).all('path', 99);
|
||||
query.and([{ color: 'green' }, { status: 'ok' }]).and([]);
|
||||
@@ -761,8 +760,9 @@ schemaArray.sparse(true);
|
||||
* section schema/string.js
|
||||
* http://mongoosejs.com/docs/api.html#schema-string-js
|
||||
*/
|
||||
var MongoDocument: mongoose.Document;
|
||||
var schemastring: mongoose.Schema.Types.String = new mongoose.Schema.Types.String('hello');
|
||||
schemastring.checkRequired(234, new mongoose.Document()).valueOf();
|
||||
schemastring.checkRequired(234, MongoDocument).valueOf();
|
||||
schemastring.enum(['hi', 'a', 'b']).enum('hi').enum({});
|
||||
schemastring.lowercase().lowercase();
|
||||
schemastring.match(/re/, 'error').match(/re/);
|
||||
@@ -790,7 +790,7 @@ documentarray.sparse(true);
|
||||
* http://mongoosejs.com/docs/api.html#schema-number-js
|
||||
*/
|
||||
var schemanumber: mongoose.Schema.Types.Number = new mongoose.Schema.Types.Number('num', {});
|
||||
schemanumber.checkRequired(999, new mongoose.Document()).valueOf();
|
||||
schemanumber.checkRequired(999, MongoDocument).valueOf();
|
||||
schemanumber.max(999, 'error').max(999);
|
||||
schemanumber.min(999, 'error').min(999);
|
||||
/* static properties */
|
||||
@@ -803,7 +803,7 @@ schemanumber.sparse(true);
|
||||
* http://mongoosejs.com/docs/api.html#schema-date-js
|
||||
*/
|
||||
var schemadate: mongoose.Schema.Types.Date = new mongoose.Schema.Types.Date('99');
|
||||
schemadate.checkRequired([], new mongoose.Document()).valueOf();
|
||||
schemadate.checkRequired([], MongoDocument).valueOf();
|
||||
schemadate.expires(99).expires('now');
|
||||
schemadate.max(new Date(), 'error').max(new Date(''));
|
||||
schemadate.min(new Date(), 'error').min(new Date(''));
|
||||
@@ -817,7 +817,7 @@ schemadate.sparse(true);
|
||||
* http://mongoosejs.com/docs/api.html#schema-buffer-js
|
||||
*/
|
||||
var schemabuffer: mongoose.Schema.Types.Buffer = new mongoose.Schema.Types.Buffer('99');
|
||||
schemabuffer.checkRequired(999, new mongoose.Document()).valueOf();
|
||||
schemabuffer.checkRequired(999, MongoDocument).valueOf();
|
||||
/* static properties */
|
||||
mongoose.Schema.Types.Buffer.schemaName.toLowerCase();
|
||||
/* inherited properties */
|
||||
@@ -840,7 +840,7 @@ schemaboolean.sparse(true);
|
||||
*/
|
||||
var schemaobjectid: mongoose.Schema.Types.ObjectId = new mongoose.Schema.Types.ObjectId('99');
|
||||
schemaobjectid.auto(true).auto(false);
|
||||
schemaobjectid.checkRequired(99, new mongoose.Document()).valueOf();
|
||||
schemaobjectid.checkRequired(99, MongoDocument).valueOf();
|
||||
/* static properties */
|
||||
mongoose.Schema.Types.ObjectId.schemaName.toLowerCase();
|
||||
/* inherited properties */
|
||||
@@ -1078,7 +1078,7 @@ var MongoModel = mongoose.model('MongoModel', new mongoose.Schema({
|
||||
required: true
|
||||
}
|
||||
}), 'myCollection', true);
|
||||
MongoModel.$where('indexOf("val") !== -1').exec(function (err, docs) {
|
||||
MongoModel.find({}).$where('indexOf("val") !== -1').exec(function (err, docs) {
|
||||
docs[0].save();
|
||||
});
|
||||
MongoModel.findById(999, function (err, doc) {
|
||||
@@ -1310,7 +1310,7 @@ LocModel.find()
|
||||
});
|
||||
});
|
||||
});
|
||||
LocModel.$where('')
|
||||
LocModel.find({}).$where('')
|
||||
.exec(function (err, locations) {
|
||||
locations[0].name;
|
||||
locations[1].openingTimes;
|
||||
@@ -1346,10 +1346,22 @@ LocModel.geoSearch({}, {
|
||||
interface IStatics {
|
||||
staticMethod2: (a: number) => string;
|
||||
}
|
||||
var StaticModel = mongoose.model<Location, IStatics>('Location');
|
||||
StaticModel.staticMethod2(9).toUpperCase();
|
||||
(new StaticModel()).save(function (err, doc) {
|
||||
doc.openingTimes;
|
||||
doc.model<Location, IStatics>('').staticMethod2;
|
||||
});
|
||||
StaticModel.model<Location, IStatics>('').staticMethod2;
|
||||
interface MyDocument extends mongoose.Document {
|
||||
prop: string;
|
||||
method: () => void;
|
||||
}
|
||||
interface MyModel extends mongoose.Model<MyDocument> {
|
||||
staticProp: string;
|
||||
staticMethod: () => void;
|
||||
}
|
||||
interface ModelStruct {
|
||||
doc: MyDocument,
|
||||
model: MyModel
|
||||
}
|
||||
var mySchema = new mongoose.Schema({});
|
||||
export var Final: MyModel = <MyModel>mongoose.connection.model<MyDocument>('Final', mySchema);
|
||||
Final.findOne(function (err: any, doc: MyDocument) {
|
||||
doc.save();
|
||||
doc.remove();
|
||||
doc.model<null>(null, null);
|
||||
});
|
||||
Vendored
+2270
-2391
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user