(type, schema, model, options, callback, controller, novalidate)
| 716 | |
| 717 | // type, schema, model, options, callback, controller |
| 718 | function performschema(type, schema, model, options, callback, controller, novalidate) { |
| 719 | |
| 720 | if (typeof(options) === 'function') { |
| 721 | novalidate = controller; |
| 722 | controller = callback; |
| 723 | callback = options; |
| 724 | options = null; |
| 725 | } |
| 726 | |
| 727 | var o = framework_builders.getschema(schema); |
| 728 | |
| 729 | if (!o) { |
| 730 | callback && callback(new Error('Schema "{0}" not found.'.format(getSchemaName(schema)))); |
| 731 | return false; |
| 732 | } |
| 733 | |
| 734 | var workflow = {}; |
| 735 | workflow[type.substring(1)] = 1; |
| 736 | |
| 737 | var req = controller ? controller.req : null; |
| 738 | var keys; |
| 739 | |
| 740 | if (type === '$patch') { |
| 741 | keys = Object.keys(model); |
| 742 | if (req) |
| 743 | req.$patch = true; |
| 744 | else |
| 745 | req = { $patch: true }; |
| 746 | } |
| 747 | |
| 748 | o.make(model, null, function(err, model) { |
| 749 | if (err) { |
| 750 | callback && callback(err); |
| 751 | } else { |
| 752 | model.$$keys = keys; |
| 753 | model.$$controller = controller; |
| 754 | model[type](options, callback); |
| 755 | if (req && req.$patch && req.method && req.method !== 'PATCH') |
| 756 | delete req.$patch; |
| 757 | } |
| 758 | }, null, novalidate, workflow, req); |
| 759 | |
| 760 | return !!o; |
| 761 | } |
| 762 | |
| 763 | global.$ASYNC = function(schema, callback, index, controller) { |
| 764 |
no test coverage detected