<commit_before>package js.npm.mongoose;

import haxe.extern.Rest;
import js.support.Callback;
import js.support.Error;

typedef ModelUpdateOptions = {
	?safe: Bool,
	?upsert: Bool,
	?multi: Bool,
	?strict: Bool,
	?overwrite: Bool,
	?runValidators:Bool
}

typedef ModelUpdateCallback = Callback1<{
	ok:Int,
	?nModified:Int,
	n:Int
}>;

@:native("Model")
extern class TModel<T>
extends Document<T>
implements npm.Package.RequireNamespace<"mongoose","^4.3.3"> 
{

	public var db : Connection;
	public var collection : Dynamic;//Collection;
	public var modelName : String;
	
	@:overload(function(): Void {})
	@:overload(function(fn: Callback2<TModel<T>, Int>): Void {})
	public function save( fn : Callback<TModel<T>> ) : Void;
	public function increment() : TModel<T>;
	public function remove( ?fn : Callback<TModel<T>> ) : TModel<T>;

	public function model<T,M:TModel<T>>( name : String ) : TModels<T,M>;
}

// just add a helper to type models a minimum
extern class Model<T>
extends TModel<T> {
	public var _ (get,null) : T;
	inline private function get__() : T return untyped this;
}

extern typedef Models<T> = TModels<T,Model<T>>;

@:native("{}")
extern class TModels<T,M:TModel<T>> {
	public var db : Connection;
	public var collection : Dynamic;//Collection;
	public var modelName : String;
	public var schema : Schema<T>;
	public var base : Mongoose;

	public function discriminator<U,N:TModel<U>>(name : String, schema : Schema<U>) : TModels<U,N>;
	
	public function ensureIndexes( ?fn : Callback0 ) : Void;
	public function remove( conditions : {} , callback : Callback0 ) : Void;

	@:overload( function ( conditions : {} , fields : String , callback : Callback<Array<M>> ): Query<Array<M>> {} )
	@:overload( function ( conditions : {} , fields : String , options : {} , ?callback : Callback<Array<Model<T>>> ): Query<Array<M>> {} )
	@:overload( function ( conditions : {} , fields : Null<{}> , ?callback : Callback<Array<M>> ): Query<Array<M>> {} )
	@:overload( function ( conditions : {} , fields : Null<{}> , options : {} , ?callback : Callback<Array<M>> ): Query<Array<M>> {} )
	public function find( ?conditions : {} , ?callback : Callback<Array<M>> ): Query<Array<M>>; // Query<Model<T>>

	@:overload( function( id : Dynamic , callback : Callback<Null<M>> ) : Void {} )
	@:overload( function ( id : Dynamic , fields : String , options : {} , ?callback : Callback<Null<M>> ): Query<M> {} )
	@:overload( function ( id : Dynamic , fields : Null<{}> , options : {} , ?callback : Callback<Null<M>> ): Query<M> {} )
	public function findById( id : Dynamic ): Query<M>; // Query<Model<T>>

	@:overload( function( conditions : {} , callback : Callback<Null<M>> ) : Void {} )
	@:overload( function ( conditions : {}  , fields : String , options : {} , ?callback : Callback<Null<M>> ): Query<M> {} )
	@:overload( function ( conditions : {} , fields : Null<{}> , options : {} , ?callback : Callback<Null<M>> ): Query<M> {} )
	public function findOne( ?conditions : {} ): Query<M>; // Query<M>

	@:overload( function ( conditions : {} , ?callback : Callback<Int> ): Query<M> {} )// Query<M>
	public function count( callback : Callback<Int> ): Query<M>; // Query<M>

	@:overload( function ( field : String ): Query<M> {} )// Query<M>
	@:overload( function ( field : String , conditions : {} , callback : Callback<Array<M>> ): Query<M> {} )// Query<M>
	@:overload( function ( field : String , conditions : {} ): Query<M> {} )// Query<M>
	public function distinct( field : String , callback : Callback<Array<M>> ): Query<M>; // Query<M>

	public function where( field : String , ?val : Dynamic ) : Query<Array<M>>;

	@:overload( function( conditions : Void->Bool ) : Query<Array<M>> {} )
	public inline function _where( conditions : String ) : Query<Array<M>> return untyped this["$where"](conditions);
<commit_msg>More method overloads for mongoose models<commit_after>package js.npm.mongoose;

import haxe.extern.Rest;
import js.support.Callback;
import js.support.Error;

typedef ModelUpdateOptions = {
	?safe: Bool,
	?upsert: Bool,
	?multi: Bool,
	?strict: Bool,
	?overwrite: Bool,
	?runValidators:Bool
}

typedef ModelUpdateCallback = Callback1<{
	ok:Int,
	?nModified:Int,
	n:Int
}>;

@:native("Model")
extern class TModel<T>
extends Document<T>
implements npm.Package.RequireNamespace<"mongoose","^4.3.3"> 
{

	public var db : Connection;
	public var collection : Dynamic;//Collection;
	public var modelName : String;
	
	@:overload(function(): Void {})
	@:overload(function(fn: Callback2<TModel<T>, Int>): Void {})
	public function save( fn : Callback<TModel<T>> ) : Void;
	public function increment() : TModel<T>;
	public function remove( ?fn : Callback<TModel<T>> ) : TModel<T>;

	public function model<T,M:TModel<T>>( name : String ) : TModels<T,M>;
}

// just add a helper to type models a minimum
extern class Model<T>
extends TModel<T> {
	public var _ (get,null) : T;
	inline private function get__() : T return untyped this;
}

extern typedef Models<T> = TModels<T,Model<T>>;

@:native("{}")
extern class TModels<T,M:TModel<T>> {
	public var db : Connection;
	public var collection : Dynamic;//Collection;
	public var modelName : String;
	public var schema : Schema<T>;
	public var base : Mongoose;

	public function discriminator<U,N:TModel<U>>(name : String, schema : Schema<U>) : TModels<U,N>;
	
	public function ensureIndexes( ?fn : Callback0 ) : Void;
	public function remove( conditions : {} , callback : Callback0 ) : Void;

	@:overload( function ( conditions : {} , fields : String , callback : Callback<Array<M>> ): Query<Array<M>> {} )
	@:overload( function ( conditions : {} , fields : String , options : {} , ?callback : Callback<Array<Model<T>>> ): Query<Array<M>> {} )
	@:overload( function ( conditions : {} , fields : Null<{}> , ?callback : Callback<Array<M>> ): Query<Array<M>> {} )
	@:overload( function ( conditions : {} , fields : Null<{}> , options : {} , ?callback : Callback<Array<M>> ): Query<Array<M>> {} )
	public function find( ?conditions : {} , ?callback : Callback<Array<M>> ): Query<Array<M>>; // Query<Model<T>>

	@:overload( function( id : Dynamic , callback : Callback<Null<M>> ) : Void {} )
	@:overload( function( id : Dynamic , options : {} , ?callback : Callback<Null<M>> ) : Query<M> {} )
	@:overload( function ( id : Dynamic , fields : String , options : {} , ?callback : Callback<Null<M>> ): Query<M> {} )
	@:overload( function ( id : Dynamic , fields : Null<{}> , options : {} , ?callback : Callback<Null<M>> ): Query<M> {} )
	public function findById( id : Dynamic ): Query<M>; // Query<Model<T>>

	@:overload( function( conditions : {} , callback : Callback<Null<M>> ) : Void {} )
	@:overload( function( conditions : {} , options : {} , ?callback : Callback<Null<M>> ) : Query<M> {} )
	@:overload( function ( conditions : {}  , fields : String , options : {} , ?callback : Callback<Null<M>> ): Query<M> {} )
	@:overload( function ( conditions : {} , fields : Null<{}> , options : {} , ?callback : Callback<Null<M>> ): Query<M> {} )
	public function findOne( ?conditions : {} ): Query<M>; // Query<M>

	@:overload( function ( conditions : {} , ?callback : Callback<Int> ): Query<M> {} )// Query<M>
	public function count( callback : Callback<Int> ): Query<M>; // Query<M>

	@:overload( function ( field : String ): Query<M> {} )// Query<M>
	@:overload( function ( field : String , conditions : {} , callback : Callback<Array<M>> ): Query<M> {} )// Query<M>
	@:overload( function ( field : String , conditions : {} ): Query<M> {} )// Query<M>
	public function distinct( field : String , callback : Callback<Array<M>> ): Query<M>; // Query<M>

	public function where( field : String , ?val : Dynamic ) : Query<Array<M>>;

	@:overload( function( conditions : Void->Bool ) : Query<Array<M>> {} )
	public inline function _where( conditions : String ) : Query<Array<M>> return untyped this["$where"](conditions);

{'fraction_non_alphanumeric': 0.1862358478565068, 'fraction_numerical': 0.0017809439002671415, 'mean_word_length': 4.797935103244837, 'pattern_counts': {'":': 0, '<': 207, '<?xml version=': 0, '>': 209, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7286081', 'n_tokens_mistral': 2681, 'n_tokens_neox': 2594, 'n_words': 666}