command
node index.js test1
node index.js test2
result
const mongoose = require('mongoose'); | |
const kittySchema = new mongoose.Schema({ | |
name: String | |
}); | |
const Kitten = mongoose.model('Kitten', kittySchema); | |
const CONNECTION_STRING = process.env.MONGODB_TEST_URL + '/' + process.argv[2] | |
async function main() { | |
await mongoose.connect(CONNECTION_STRING); | |
const cat = new Kitten({ name: 'cat one' }); | |
await cat.save(); | |
const cats = await Kitten.find(); | |
console.log({ cats }) | |
process.exit(0) | |
} | |
main().catch(err => console.log(err)); |