deno.land / x / mongoose@6.7.5 / test / collection.capped.test.js

collection.capped.test.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/** * Module dependencies. */
'use strict';
const start = require('./common');
const assert = require('assert');
const mongoose = start.mongoose;const Schema = mongoose.Schema;

/** * Test. */
describe('collections: capped:', function() { let db;
before(function() { db = start(); });
after(async function() { await db.close(); });
it('schemas should have option size', function() { const capped = new Schema({ key: String }); capped.set('capped', { size: 1000 });
assert.ok(capped.options.capped); assert.equal(capped.options.capped.size, 1000); });
it('creation', async function() { this.timeout(15000);
await db.dropCollection('Test').catch(() => {});
const capped = new Schema({ key: String }); capped.set('capped', { size: 1000 }); const Capped = db.model('Test', capped, 'Test'); await Capped.init(); await new Promise((resolve) => setTimeout(resolve, 100));
const isCapped = await Capped.collection.isCapped(); assert.ok(isCapped); });
it('skips when setting autoCreate to false (gh-8566)', async function() { const db = start(); this.timeout(30000); await db.dropDatabase();
const schema = new mongoose.Schema({ name: String }, { capped: { size: 1024 }, bufferCommands: false, autoCreate: false // disable `autoCreate` since `bufferCommands` is false });
const Model = db.model('Test', schema); // Explicitly create the collection before using it // so the collection is capped. await Model.createCollection({ capped: true, size: 1024 });
// Should not throw await Model.create({ name: 'test' });
await db.dropDatabase(); });});
mongoose

Version Info

Tagged at
a year ago