Skip to content

Commit ed7f992

Browse files
committed
expose data and schema to dev console
1 parent 200eff6 commit ed7f992

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

scout-ui/src/models/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@ var _ = require('underscore');
1313
var es = require('event-stream');
1414
var Schema = require('mongodb-schema').Schema;
1515

16+
// Yay! Use the API from the devtools console.
1617
window.scout = client;
1718

19+
// Handy debugging! Just type `data` in the devtools console to see the array
20+
// of documents currently in the schema.
21+
window.data = [];
22+
23+
// The currently active schema.
24+
window.schema = null;
25+
1826
var wrapError = require('./wrap-error');
1927

2028
/**
@@ -36,10 +44,15 @@ var SampledSchema = Schema.extend({
3644
wrapError(this, options);
3745

3846
var model = this;
47+
window.schema = this;
48+
window.data = [];
3949
var parser = this.stream()
4050
.on('error', function(err) {
4151
options.error(err, 'error', err.message);
4252
})
53+
.on('data', function(doc) {
54+
window.data.push(doc);
55+
})
4356
.on('end', function() {
4457
process.nextTick(function() {
4558
model.trigger('sync', model, model.serialize(), options);

0 commit comments

Comments
 (0)