Quantcast
Channel: mongoDB can't createCollection() nodejs? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

mongoDB can't createCollection() nodejs?

$
0
0

I am using mongoose with node.js, I have a file called models.js where I define my schema then export them.

module.exports = {    Team   : mongoose.model('Team', Team),    Player : mongoose.model('Player', Player)};

When I want to query the DB I run commands like

models.Team.find({}, function(err, teams) {    console.log(teams); // this lists all the teams just fine, function works});

But I am trying to create a new collection so I can save my Players collection into a new one then clear the collection. So I am trying the below and I get has no method 'createCollection'

models.Player.createCollection('week1');

I have also tried the below, not really sure how to define my target lol but I have used robo mongo to create a collection called test

models.Player.copyTo('test')

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images