Skip to content

Commit 2e5aeed

Browse files
committed
Added SchemaBuilderEntity.$output().
1 parent 79b078d commit 2e5aeed

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

builders.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,6 +1996,11 @@ SchemaInstance.prototype.$callback = function(callback) {
19961996
return this;
19971997
};
19981998

1999+
SchemaInstance.prototype.$output = function() {
2000+
this.$$index = this.$$result.length;
2001+
return this;
2002+
};
2003+
19992004
SchemaInstance.prototype.$push = function(type, name, helper, first) {
20002005

20012006
var self = this;

changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- added: `SchemaBuilderEntity.$index(index)` can changed `obj.$async()` index (the index can be string e.g. `+1` or `-1`)
88
- added: `SchemaBuilderEntity.$callback(fn)` can changed `obj.$async()` callback
99
- added: `SchemaBuilderEntity.$repository(name, [value])` can get / set temporary value
10+
- added: `SchemaBuilderEntity.$output()` sets the current `callback(value)` as output/result for `obj.$async(function(err, output))`
1011

1112
- updated: when the config contains `directory-temp` with empty value then the framework uses system temporary directory
1213

test/test-builders.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,29 @@ function test_ErrorBuilder() {
537537
}).$workflow('1').$workflow('2');
538538
});
539539

540+
541+
NEWSCHEMA('Output').make(function(schema) {
542+
543+
schema.addWorkflow('1', function(error, model, options, callback) {
544+
callback(1);
545+
});
546+
547+
schema.addWorkflow('2', function(error, model, options, callback) {
548+
model.$output();
549+
callback(2);
550+
});
551+
552+
schema.addWorkflow('3', function(error, model, options, callback) {
553+
callback(3);
554+
});
555+
556+
var model = schema.create();
557+
558+
model.$async(function(err, response) {
559+
assert.ok(response === 2, 'SchemaBuilderEntity.$output()');
560+
}).$workflow('1').$workflow('2').$workflow('3');
561+
});
562+
540563
};
541564

542565
function test_TransformBuilder() {

0 commit comments

Comments
 (0)