Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mongoose rename collection

const mongoose   = require('mongoose');
mongoose.Promise = Promise;

mongoose.connect('mongodb://localhost/test').then(() => {
  console.log('connected');

  // Access the underlying database object provided by the MongoDB driver.
  let db = mongoose.connection.db;

  // Rename the `test` collection to `foobar`
  return db.collection('test').rename('foobar');
}).then(() => {
  console.log('rename successful');
}).catch(e => {
  console.log('rename failed:', e.message);
}).then(() => {
  console.log('disconnecting');
  mongoose.disconnect();
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: find object in array 
Javascript :: how to code a discord bot in javascript 
Javascript :: import react js video player 
Javascript :: vue css 
Javascript :: js filter method in python 
Javascript :: how to clear a function in javascript 
Javascript :: get all files in directory recursively nodejs 
Javascript :: install react-native-safe-area-context 
Javascript :: jquery get native element 
Javascript :: footer bottom 
Javascript :: useRoutes 
Javascript :: delete message plugin discord 
Javascript :: ${ js 
Javascript :: how to connect mongodb with next js 
Javascript :: javascript swap 
Javascript :: javascript get object in object 
Javascript :: optional chaining 
Javascript :: passing multiple props to child component in react 
Javascript :: jquery get element by tag 
Javascript :: npm jsonwebtoken 
Javascript :: javascript for in 
Javascript :: open modal on clicking select option in react 
Javascript :: date javascript 
Javascript :: javascript escape character 
Javascript :: events onclick 
Javascript :: get datepicker value date 
Javascript :: js 1 minute sleep 
Javascript :: what does event emitter do in angular 
Javascript :: map in js 
Javascript :: The element.onclick Property 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =