Skip to content

Commit bdf2707

Browse files
committed
fix(data): add mixed types schema (contacts)
1 parent 2add56a commit bdf2707

File tree

5 files changed

+55
-14
lines changed

5 files changed

+55
-14
lines changed

scout-data/contacts-boolean.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"_id": "{{ObjectID()}}",
3+
"contacts": ["{{_$config}}", {}, {
4+
"name": "{{chance.name()}}",
5+
"email": "{{chance.email()}}",
6+
"invitation_accepted": "{{Boolean(chance.bool())}}"
7+
}]
8+
}

scout-data/contacts-number.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"_id": "{{ObjectID()}}",
3+
"contacts": ["{{_$config}}", {}, {
4+
"name": "{{chance.name()}}",
5+
"email": "{{chance.email()}}",
6+
"invitation_accepted": "{{Number(chance.bool())}}"
7+
}]
8+
}

scout-data/contacts-string.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"_id": "{{ObjectID()}}",
3+
"contacts": ["{{_$config}}", {}, {
4+
"name": "{{chance.name()}}",
5+
"email": "{{chance.email()}}",
6+
"invitation_accepted": "{{chance.bool()}}"
7+
}]
8+
}

scout-data/index.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,51 @@ var createUsers = function(opts) {
1414
})).pipe(dest);
1515
};
1616

17-
var createPaymentMethods = function(opts) {
17+
var createContactsNumber = function(opts) {
1818
var dest = new MongoWritableStream({
1919
url: opts.url,
20-
collection: 'payment_methods'
20+
collection: 'contacts'
2121
});
22-
var src = fs.createReadStream(__dirname + '/payment-methods.json');
22+
var src = fs.createReadStream(__dirname + '/contacts-number.json');
23+
return src.pipe(datasets.createGeneratorStream({
24+
size: 1000
25+
})).pipe(dest);
26+
};
27+
var createContactsString = function(opts) {
28+
var dest = new MongoWritableStream({
29+
url: opts.url,
30+
collection: 'contacts'
31+
});
32+
var src = fs.createReadStream(__dirname + '/contacts-string.json');
33+
return src.pipe(datasets.createGeneratorStream({
34+
size: 1000
35+
})).pipe(dest);
36+
};
37+
var createContactsBoolean = function(opts) {
38+
var dest = new MongoWritableStream({
39+
url: opts.url,
40+
collection: 'contacts'
41+
});
42+
var src = fs.createReadStream(__dirname + '/contacts-boolean.json');
2343
return src.pipe(datasets.createGeneratorStream({
2444
size: 1000
2545
})).pipe(dest);
2646
};
27-
2847
module.exports = function(opts, done) {
2948
opts = opts || {};
3049
opts.url = opts.url || 'mongodb://localhost:27017/datasets';
3150
async.parallel({
3251
users: function(cb) {
3352
createUsers(opts).on('end', cb);
3453
},
35-
payment_methods: function(cb) {
36-
createPaymentMethods(opts).on('end', cb);
54+
contacts_string: function(cb) {
55+
createContactsString(opts).on('end', cb);
56+
},
57+
contacts_number: function(cb) {
58+
createContactsNumber(opts).on('end', cb);
59+
},
60+
contacts_boolean: function(cb) {
61+
createContactsBoolean(opts).on('end', cb);
3762
}
3863
}, done);
3964
};

scout-data/payment-methods.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)