Model Methods: Drop Index
Deleting an index from a collection in the database in MerlinDB.
🪶 The dropIndex method is used to delete an index from the collection, once deleted the index can no longer be accessed.
1 import MerlinDB, { Schema} from "@chrisaxxwell/merlin-db";2 //Or if you are using 'merlindb.max.js' just call 'new MerlinDB()'; 3 4 const merlin = new MerlinDB( ) ;5 merlin.connect( "USER-DATABASE") ; 6 7 const UserSchema = Schema( { 8 name: String , 9 age: Number 10 } ) ; 11 12 var userModel = merlin.model( "User", UserSchema) ;13 14 //userModel.dropIndex(); 15 userModel.dropIndex( "email") .then( e => console.log( e) ) 16 //returns: 17 { 18 "msg": "index 'X' dropped for collection!", 19 "ok": 1 20 }