MongoDB Tutorial #9 - Dropping a Collection

preview_player
Показать описание
Hey gang, in this mongodb tutorial I'll show you how to drop a collection using one of mongoose's methods.

----- COURSE LINKS:

---------------------------------------------------------------------------------------------

========== PSD to WordPress Playlist ==========

============== The Net Ninja =====================

================== Social Links ==================

Рекомендации по теме
Комментарии
Автор

Outstanding tutorial style. You explain as you go bit by bit and you repeatedly walk through exactly what's happening in plain English. Most just barrel through the code they are retyping from in another window.

onesun
Автор

Your tutorials are amazing, been watching a bunch of them. Looking forward to the rest of this series. Thanks a lot for your work, it's helped me so much !

tv-bbvg
Автор

it feels like a mocha tutorial more than a mongo's, i just came here for mongo i wish you would separate things more next times, thanks

bashardlaleh
Автор

Great tutorials. TypeScript would be nice to see aswell in the future.

ludwighallgren
Автор

Looking forward to seeing more. Question - why are we dropping the collections ? I understand this particular case example, but is this a common practice ? Not sure if I were to be using this approach myself. I can just click last record in robomongo I suppose (?)

maciejs
Автор

If you are not able to use collection.mariochars.drop()
Try this, Since we are trying to drop a complete database and not just an instance.



If you just need to drop an instance of 'Mario', use :
mongoose.connection.db.dropCollection('Mario', function(){done();});

yeshodharab
Автор

Where can i find the physical database?
For example if i want to move it to another server/pc?

darsul
Автор

I hope after this course you will do courses about Object oriented javascript.

Кулити-кч
Автор

for those who are receiving the error, drop is not a function try this instead:
beforeEach(function (done) {
mongoose.connection.db.dropCollection('mariochars', function (err, result) {
done();
})
})

Alex-csoc
Автор

how does the 'done()' function actually work???

govardhangd
Автор

Cool tuts king of ninjas, you mean by test the it blocks?

nasrallahal-shaer
Автор

all working fine but not terminating npm run test even after doing with done() could you please help me on this

sunilpatra
Автор

So before is run before a test (that means the first test that it encounter) then beforeeach is run before each test?

diethermarcelo
Автор

I have error message when I try to connect test:
"before all" hook in "{root}":
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

mariuszjanowski
Автор

I only like his 'yeah' in between...

muhammadsiddiqui
Автор

This worked for me in the beforeEach clause: mongoose.connection.dropCollection('mariochars', () => done())

idontwhy
Автор

great serie tutorial, but why did you use test, I supposed to only learn mongo and not mocha ?

LifeIsGood
Автор

is there any other way to check if the records got deleted without robomongo?

HaBhBo
Автор

I did not find any mario each time after running the test. Both test db and testaroo db are empty. Are they deleted automatically after ever test?

Oh forgive me I made a mistake. The data are indeed duplicated, and are not deleted automatically. I made a wrong query, to a db rather than a collection then it returned 0.

chenxuanwang
Автор

If some one has this problem Running Mocha: "before each" hook for "save a record to db":
TypeError: is not a function

I resolver with this modify in connections.js

beforeEach((done)=>{
// modified dropCollection works!!
mongoose.connection.dropCollection('marios', ()=>{
done();
});
});

leavventuredistellanelpaes