Skip to content

Instantly share code, notes, and snippets.

@smpnjn
Created April 21, 2021 20:43
Show Gist options
  • Save smpnjn/d58ecf16562a01c8c6ab7a2f8e404e32 to your computer and use it in GitHub Desktop.
Save smpnjn/d58ecf16562a01c8c6ab7a2f8e404e32 to your computer and use it in GitHub Desktop.
import mongoose from 'mongoose'
const database = 'mongodb://localhost:27017/articles';
const connection = mongoose.createConnection(database, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false
});
const schema = new mongoose.Schema({
title: 'String',
description: 'String',
articleText: 'String',
date: 'Number'
});
const Article = connection.model('Article', schema);
export { Article };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment