deno.land / x / mongoose@6.7.5 / examples / statics / statics.js
12345678910111213141516171819202122232425262728293031323334'use strict';const mongoose = require('../../lib');
// import the schemarequire('./person.js')();
// grab the person model objectconst Person = mongoose.model('Person');
// connect to a server to do a quick write / read examplerun().catch(console.error);
async function run() { await mongoose.connect('mongodb://localhost/persons'); const bill = await Person.create({ name: 'bill', age: 25, birthday: new Date().setFullYear((new Date().getFullYear() - 25)) }); console.log('People added to db: %s', bill.toString());
// using the static const result = await Person.findPersonByName('bill');
console.log(result); await cleanup();}
async function cleanup() { await Person.remove(); mongoose.disconnect();}
Version Info