deno.land / x / mongoose@6.7.5 / examples / statics / statics.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'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();}
mongoose

Version Info

Tagged at
2 years ago