Added findOne to Service

This commit is contained in:
Tobe O 2018-07-12 11:08:53 -04:00
parent 13addcf982
commit 81e768cb16
2 changed files with 111 additions and 86 deletions

View file

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="" /> <list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/core/service.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/core/service.dart" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/.tmp/" /> <ignored path="$PROJECT_DIR$/.tmp/" />
<ignored path="$PROJECT_DIR$/temp/" /> <ignored path="$PROJECT_DIR$/temp/" />
<ignored path="$PROJECT_DIR$/tmp/" /> <ignored path="$PROJECT_DIR$/tmp/" />
@ -23,35 +26,32 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="parameter_meta_test.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/parameter_meta_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="416">
<caret line="26" column="17" selection-start-line="26" selection-start-column="17" selection-end-line="26" selection-end-column="17" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="false"> <file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/CHANGELOG.md"> <entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]"> <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT"> <state split_layout="SPLIT">
<first_editor relative-caret-position="16"> <first_editor relative-caret-position="16">
<caret line="1" column="50" selection-start-line="1" selection-start-column="50" selection-end-line="1" selection-end-column="50" /> <caret line="1" column="55" selection-start-line="1" selection-start-column="55" selection-end-line="1" selection-end-column="55" />
</first_editor> </first_editor>
<second_editor /> <second_editor />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="http.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/http/http.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
<caret line="18" column="26" selection-start-line="18" selection-start-column="26" selection-end-line="18" selection-end-column="26" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="angel_http.dart" pinned="false" current-in-tab="false"> <file leaf-file-name="angel_http.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart"> <entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="186"> <state relative-caret-position="4432">
<caret line="167" column="45" selection-start-line="167" selection-start-column="45" selection-end-line="167" selection-end-column="45" /> <caret line="297" column="23" selection-start-line="297" selection-start-column="23" selection-end-line="297" selection-end-column="23" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -59,8 +59,8 @@
<file leaf-file-name="hooks.dart" pinned="false" current-in-tab="false"> <file leaf-file-name="hooks.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/hooks.dart"> <entry file="file://$PROJECT_DIR$/lib/hooks.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="164"> <state relative-caret-position="2112">
<caret line="135" column="48" lean-forward="true" selection-start-line="135" selection-start-column="48" selection-end-line="135" selection-end-column="48" /> <caret line="135" column="48" selection-start-line="135" selection-start-column="48" selection-end-line="135" selection-end-column="48" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -68,17 +68,17 @@
<file leaf-file-name="pubspec.yaml" pinned="false" current-in-tab="false"> <file leaf-file-name="pubspec.yaml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/pubspec.yaml"> <entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="16"> <state relative-caret-position="80">
<caret line="1" column="17" selection-start-line="1" selection-start-column="17" selection-end-line="1" selection-end-column="17" /> <caret line="5" column="12" selection-start-line="5" selection-start-column="12" selection-end-line="5" selection-end-column="12" />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="path_set.dart" pinned="false" current-in-tab="true"> <file leaf-file-name="service.dart" pinned="false" current-in-tab="true">
<entry file="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/path-1.6.0/lib/src/path_set.dart"> <entry file="file://$PROJECT_DIR$/lib/src/core/service.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="161"> <state relative-caret-position="274">
<caret line="77" column="33" selection-start-line="77" selection-start-column="33" selection-end-line="77" selection-end-column="33" /> <caret line="78" column="40" lean-forward="true" selection-start-line="78" selection-start-column="40" selection-end-line="78" selection-end-column="40" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -86,7 +86,7 @@
<file leaf-file-name="http_response_context.dart" pinned="false" current-in-tab="false"> <file leaf-file-name="http_response_context.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/http/http_response_context.dart"> <entry file="file://$PROJECT_DIR$/lib/src/http/http_response_context.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170"> <state relative-caret-position="1360">
<caret line="89" column="49" selection-start-line="89" selection-start-column="49" selection-end-line="89" selection-end-column="49" /> <caret line="89" column="49" selection-start-line="89" selection-start-column="49" selection-end-line="89" selection-end-column="49" />
</state> </state>
</provider> </provider>
@ -113,7 +113,7 @@
<file leaf-file-name="routing_test.dart" pinned="false" current-in-tab="false"> <file leaf-file-name="routing_test.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/routing_test.dart"> <entry file="file://$PROJECT_DIR$/test/routing_test.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="352"> <state relative-caret-position="240">
<caret line="22" column="12" selection-start-line="22" selection-start-column="12" selection-end-line="22" selection-end-column="12" /> <caret line="22" column="12" selection-start-line="22" selection-start-column="12" selection-end-line="22" selection-end-column="12" />
<folding> <folding>
<element signature="e#0#17#0" expanded="true" /> <element signature="e#0#17#0" expanded="true" />
@ -134,8 +134,6 @@
</component> </component>
<component name="FindInProjectRecents"> <component name="FindInProjectRecents">
<findStrings> <findStrings>
<find>HttpHeaders.CONTE</find>
<find>HttpHeaders</find>
<find>HttpStatus.FORBIDDEN</find> <find>HttpStatus.FORBIDDEN</find>
<find>HttpStatus.</find> <find>HttpStatus.</find>
<find>JSON</find> <find>JSON</find>
@ -164,9 +162,10 @@
<find>Map&lt;String,</find> <find>Map&lt;String,</find>
<find>as</find> <find>as</find>
<find>redirectTo</find> <find>redirectTo</find>
<find>finalizers.t</find>
<find>`Iterable`</find>
</findStrings> </findStrings>
<replaceStrings> <replaceStrings>
<replace>if (_isClosed &amp;&amp; !_useStream)</replace>
<replace>logger?.warning</replace> <replace>logger?.warning</replace>
<replace>JSON.decode</replace> <replace>JSON.decode</replace>
<replace>query</replace> <replace>query</replace>
@ -196,6 +195,7 @@
<replace>as $1</replace> <replace>as $1</replace>
<replace>as Map$1</replace> <replace>as Map$1</replace>
<replace>IsInstanceOf</replace> <replace>IsInstanceOf</replace>
<replace>[Iterable]</replace>
</replaceStrings> </replaceStrings>
<dirStrings> <dirStrings>
<dir>C:\Users\thosa\Source\Angel\framework\lib</dir> <dir>C:\Users\thosa\Source\Angel\framework\lib</dir>
@ -234,7 +234,6 @@
<option value="$PROJECT_DIR$/analysis_options.yaml" /> <option value="$PROJECT_DIR$/analysis_options.yaml" />
<option value="$PROJECT_DIR$/lib/src/http/http_request_context.dart" /> <option value="$PROJECT_DIR$/lib/src/http/http_request_context.dart" />
<option value="$PROJECT_DIR$/lib/src/stats/stats.dart" /> <option value="$PROJECT_DIR$/lib/src/stats/stats.dart" />
<option value="$PROJECT_DIR$/lib/src/core/service.dart" />
<option value="$PROJECT_DIR$/lib/src/core/typed_service.dart" /> <option value="$PROJECT_DIR$/lib/src/core/typed_service.dart" />
<option value="$PROJECT_DIR$/lib/src/core/server.dart" /> <option value="$PROJECT_DIR$/lib/src/core/server.dart" />
<option value="$PROJECT_DIR$/lib/src/http/http_response_context.dart" /> <option value="$PROJECT_DIR$/lib/src/http/http_response_context.dart" />
@ -270,6 +269,7 @@
<option value="$PROJECT_DIR$/lib/src/http/angel_http.dart" /> <option value="$PROJECT_DIR$/lib/src/http/angel_http.dart" />
<option value="$PROJECT_DIR$/CHANGELOG.md" /> <option value="$PROJECT_DIR$/CHANGELOG.md" />
<option value="$PROJECT_DIR$/pubspec.yaml" /> <option value="$PROJECT_DIR$/pubspec.yaml" />
<option value="$PROJECT_DIR$/lib/src/core/service.dart" />
</list> </list>
</option> </option>
</component> </component>
@ -296,7 +296,7 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="PackagesPane" /> <pane id="AndroidView" />
<pane id="Scope"> <pane id="Scope">
<subPane subId="Project Files"> <subPane subId="Project Files">
<expand> <expand>
@ -320,6 +320,13 @@
<item name="lib" type="cbb8eebc:String" user="lib" /> <item name="lib" type="cbb8eebc:String" user="lib" />
<item name="src" type="cbb8eebc:String" user="src" /> <item name="src" type="cbb8eebc:String" user="src" />
</path> </path>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
<item name="lib" type="cbb8eebc:String" user="lib" />
<item name="src" type="cbb8eebc:String" user="src" />
<item name="core" type="cbb8eebc:String" user="core" />
</path>
<path> <path>
<item name="Root" type="cbb8eebc:String" user="Root" /> <item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" /> <item name="framework" type="cbb8eebc:String" user="framework" />
@ -341,7 +348,7 @@
<select /> <select />
</subPane> </subPane>
</pane> </pane>
<pane id="AndroidView" /> <pane id="PackagesPane" />
<pane id="ProjectPane" /> <pane id="ProjectPane" />
</panes> </panes>
</component> </component>
@ -351,6 +358,7 @@
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" /> <property name="aspect.path.notification.shown" value="true" />
<property name="dart.analysis.tool.window.force.activate" value="false" /> <property name="dart.analysis.tool.window.force.activate" value="false" />
<property name="go.gopath.indexing.explicitly.defined" value="true" />
<property name="js-jscs-nodeInterpreter" value="C:\Program Files (x86)\nodejs\node.exe" /> <property name="js-jscs-nodeInterpreter" value="C:\Program Files (x86)\nodejs\node.exe" />
<property name="js.eslint.eslintPackage" value="" /> <property name="js.eslint.eslintPackage" value="" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$" />
@ -673,13 +681,8 @@
<workItem from="1531145856019" duration="691000" /> <workItem from="1531145856019" duration="691000" />
<workItem from="1531146644160" duration="3494000" /> <workItem from="1531146644160" duration="3494000" />
<workItem from="1531151880119" duration="141000" /> <workItem from="1531151880119" duration="141000" />
</task> <workItem from="1531154836670" duration="378000" />
<task id="LOCAL-00054" summary="Angel._flattened is now accessible via `optimizedRouter`"> <workItem from="1531407760497" duration="353000" />
<created>1517975513004</created>
<option name="number" value="00054" />
<option name="presentableId" value="LOCAL-00054" />
<option name="project" value="LOCAL" />
<updated>1517975513004</updated>
</task> </task>
<task id="LOCAL-00055" summary="Used function syntax, deprecated `ResponseSerializer` typedef"> <task id="LOCAL-00055" summary="Used function syntax, deprecated `ResponseSerializer` typedef">
<created>1517975664302</created> <created>1517975664302</created>
@ -1017,13 +1020,17 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1531152011317</updated> <updated>1531152011317</updated>
</task> </task>
<option name="localTasksCounter" value="103" /> <task id="LOCAL-00103" summary="Finalizers before sending">
<created>1531155020859</created>
<option name="number" value="00103" />
<option name="presentableId" value="LOCAL-00103" />
<option name="project" value="LOCAL" />
<updated>1531155020859</updated>
</task>
<option name="localTasksCounter" value="104" />
<servers /> <servers />
</component> </component>
<component name="TestHistory"> <component name="TestHistory">
<history-entry file="All_Tests - 2018.06.10 at 19h 15m 03s.xml">
<configuration name="All Tests" configurationId="DartTestRunConfigurationType" />
</history-entry>
<history-entry file="All_Tests - 2018.06.10 at 19h 15m 55s.xml"> <history-entry file="All_Tests - 2018.06.10 at 19h 15m 55s.xml">
<configuration name="All Tests" configurationId="DartTestRunConfigurationType" /> <configuration name="All Tests" configurationId="DartTestRunConfigurationType" />
</history-entry> </history-entry>
@ -1051,9 +1058,12 @@
<history-entry file="All_Tests - 2018.07.09 at 11h 06m 50s.xml"> <history-entry file="All_Tests - 2018.07.09 at 11h 06m 50s.xml">
<configuration name="All Tests" configurationId="DartTestRunConfigurationType" /> <configuration name="All Tests" configurationId="DartTestRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="All_Tests - 2018.07.09 at 12h 48m 12s.xml">
<configuration name="All Tests" configurationId="DartTestRunConfigurationType" />
</history-entry>
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="158754000" /> <option name="totallyTimeSpent" value="159485000" />
</component> </component>
<component name="TodoView"> <component name="TodoView">
<todo-panel id="selected-file"> <todo-panel id="selected-file">
@ -1084,14 +1094,13 @@
<window_info id="UI Designer" order="2" /> <window_info id="UI Designer" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39857143" /> <window_info anchor="bottom" id="Debug" order="3" weight="0.39857143" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.32714286" /> <window_info anchor="bottom" id="TODO" order="6" weight="0.32714286" />
<window_info anchor="bottom" id="Messages" order="7" weight="0.33478895" />
<window_info anchor="right" id="Palette&#9;" order="3" /> <window_info anchor="right" id="Palette&#9;" order="3" />
<window_info id="Image Layers" order="2" /> <window_info id="Image Layers" order="2" />
<window_info anchor="right" id="Capture Analysis" order="3" /> <window_info anchor="right" id="Capture Analysis" order="3" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.4964476" weight="0.3973799" />
<window_info anchor="bottom" id="Version Control" order="7" weight="0.32905984" /> <window_info anchor="bottom" id="Version Control" order="7" weight="0.32905984" />
<window_info active="true" anchor="bottom" id="Terminal" order="7" visible="true" weight="0.44978166" /> <window_info anchor="bottom" id="Run" order="2" sideWeight="0.4964476" weight="0.3973799" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.2608376" /> <window_info anchor="bottom" id="Terminal" order="7" weight="0.44978166" />
<window_info content_ui="combo" id="Project" order="0" weight="0.26818517" />
<window_info anchor="right" id="SciView" order="4" /> <window_info anchor="right" id="SciView" order="4" />
<window_info anchor="right" id="Theme Preview" order="3" /> <window_info anchor="right" id="Theme Preview" order="3" />
<window_info id="Favorites" order="3" side_tool="true" /> <window_info id="Favorites" order="3" side_tool="true" />
@ -1104,6 +1113,7 @@
<window_info id="DB Browser" order="2" weight="0.32998413" /> <window_info id="DB Browser" order="2" weight="0.32998413" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32905984" /> <window_info anchor="bottom" id="Find" order="1" weight="0.32905984" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="bottom" id="Messages" order="7" weight="0.33478895" />
<window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="right" id="Data View" order="4" /> <window_info anchor="right" id="Data View" order="4" />
</layout> </layout>
@ -1116,7 +1126,6 @@
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" /> <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<MESSAGE value="Bring back zones; mysterious hang" />
<MESSAGE value="Fixed tests" /> <MESSAGE value="Fixed tests" />
<MESSAGE value="CHANGELOG" /> <MESSAGE value="CHANGELOG" />
<MESSAGE value="Update example" /> <MESSAGE value="Update example" />
@ -1141,7 +1150,8 @@
<MESSAGE value="* Apply `fold` in `redirectToAction`; bump version -&gt; 1.1.4+9" /> <MESSAGE value="* Apply `fold` in `redirectToAction`; bump version -&gt; 1.1.4+9" />
<MESSAGE value="Patch" /> <MESSAGE value="Patch" />
<MESSAGE value="Bump" /> <MESSAGE value="Bump" />
<option name="LAST_COMMIT_MESSAGE" value="Bump" /> <MESSAGE value="Finalizers before sending" />
<option name="LAST_COMMIT_MESSAGE" value="Finalizers before sending" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
@ -1190,13 +1200,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="168">
<caret line="155" column="15" lean-forward="true" selection-start-line="155" selection-start-column="15" selection-end-line="155" selection-end-column="15" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/typed_service.dart"> <entry file="file://$PROJECT_DIR$/lib/src/core/typed_service.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255"> <state relative-caret-position="255">
@ -1325,13 +1328,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/http.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
<caret line="18" column="26" selection-start-line="18" selection-start-column="26" selection-end-line="18" selection-end-column="26" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/map_service.dart"> <entry file="file://$PROJECT_DIR$/lib/src/core/map_service.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="192"> <state relative-caret-position="192">
@ -1350,9 +1346,6 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="448"> <state relative-caret-position="448">
<caret line="28" column="17" selection-start-line="28" selection-start-column="17" selection-end-line="28" selection-end-column="17" /> <caret line="28" column="17" selection-start-line="28" selection-start-column="17" selection-end-line="28" selection-end-column="17" />
<folding>
<element signature="e#0#54#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
@ -1367,9 +1360,6 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="436"> <state relative-caret-position="436">
<caret line="39" column="11" selection-start-line="39" selection-start-column="11" selection-end-line="39" selection-end-column="11" /> <caret line="39" column="11" selection-start-line="39" selection-start-column="11" selection-end-line="39" selection-end-column="11" />
<folding>
<element signature="e#38#92#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
@ -1417,7 +1407,7 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/test/parameter_meta_test.dart"> <entry file="file://$PROJECT_DIR$/test/parameter_meta_test.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="416"> <state relative-caret-position="336">
<caret line="26" column="17" selection-start-line="26" selection-start-column="17" selection-end-line="26" selection-end-column="17" /> <caret line="26" column="17" selection-start-line="26" selection-start-column="17" selection-end-line="26" selection-end-column="17" />
<folding> <folding>
<element signature="e#0#20#0" expanded="true" /> <element signature="e#0#20#0" expanded="true" />
@ -1427,7 +1417,7 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/test/routing_test.dart"> <entry file="file://$PROJECT_DIR$/test/routing_test.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="352"> <state relative-caret-position="240">
<caret line="22" column="12" selection-start-line="22" selection-start-column="12" selection-end-line="22" selection-end-column="12" /> <caret line="22" column="12" selection-start-line="22" selection-start-column="12" selection-end-line="22" selection-end-column="12" />
<folding> <folding>
<element signature="e#0#17#0" expanded="true" /> <element signature="e#0#17#0" expanded="true" />
@ -1451,29 +1441,37 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/http_response_context.dart"> <entry file="file://$PROJECT_DIR$/lib/src/http/http_response_context.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170"> <state relative-caret-position="1360">
<caret line="89" column="49" selection-start-line="89" selection-start-column="49" selection-end-line="89" selection-end-column="49" /> <caret line="89" column="49" selection-start-line="89" selection-start-column="49" selection-end-line="89" selection-end-column="49" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/hooks.dart"> <entry file="file://$PROJECT_DIR$/lib/hooks.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="164"> <state relative-caret-position="2112">
<caret line="135" column="48" lean-forward="true" selection-start-line="135" selection-start-column="48" selection-end-line="135" selection-end-column="48" /> <caret line="135" column="48" selection-start-line="135" selection-start-column="48" selection-end-line="135" selection-end-column="48" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file:///usr/local/Cellar/dart/2.0.0-dev.65.0/libexec/lib/async/future.dart"> <entry file="file:///usr/local/Cellar/dart/2.0.0-dev.65.0/libexec/lib/async/future.dart" />
<entry file="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/path-1.6.0/lib/src/path_set.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="117"> <state relative-caret-position="470">
<caret line="631" column="39" selection-start-line="631" selection-start-column="39" selection-end-line="631" selection-end-column="39" /> <caret line="77" column="33" selection-start-line="77" selection-start-column="33" selection-end-line="77" selection-end-column="33" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/http.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
<caret line="18" column="26" selection-start-line="18" selection-start-column="26" selection-end-line="18" selection-end-column="26" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart"> <entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="186"> <state relative-caret-position="4432">
<caret line="167" column="45" selection-start-line="167" selection-start-column="45" selection-end-line="167" selection-end-column="45" /> <caret line="297" column="23" selection-start-line="297" selection-start-column="23" selection-end-line="297" selection-end-column="23" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -1481,7 +1479,7 @@
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]"> <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT"> <state split_layout="SPLIT">
<first_editor relative-caret-position="16"> <first_editor relative-caret-position="16">
<caret line="1" column="50" selection-start-line="1" selection-start-column="50" selection-end-line="1" selection-end-column="50" /> <caret line="1" column="55" selection-start-line="1" selection-start-column="55" selection-end-line="1" selection-end-column="55" />
</first_editor> </first_editor>
<second_editor /> <second_editor />
</state> </state>
@ -1489,15 +1487,15 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/pubspec.yaml"> <entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="16"> <state relative-caret-position="80">
<caret line="1" column="17" selection-start-line="1" selection-start-column="17" selection-end-line="1" selection-end-column="17" /> <caret line="5" column="12" selection-start-line="5" selection-start-column="12" selection-end-line="5" selection-end-column="12" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/path-1.6.0/lib/src/path_set.dart"> <entry file="file://$PROJECT_DIR$/lib/src/core/service.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="161"> <state relative-caret-position="274">
<caret line="77" column="33" selection-start-line="77" selection-start-column="33" selection-end-line="77" selection-end-column="33" /> <caret line="78" column="40" lean-forward="true" selection-start-line="78" selection-start-column="40" selection-end-line="78" selection-end-column="40" />
</state> </state>
</provider> </provider>
</entry> </entry>

View file

@ -64,6 +64,33 @@ class Service extends Routable {
/// Closes this service, including any database connections or stream controllers. /// Closes this service, including any database connections or stream controllers.
void close() {} void close() {}
/// Retrieves the first object from the result of calling [index] with the given [params].
///
/// If the result of [index] is `null`, OR an empty [Iterable], a 404 `AngelHttpException` will be thrown.
///
/// If the result is both non-null and NOT an [Iterable], it will be returned as-is.
///
/// If the result is a non-empty [Iterable], [findOne] will return `it.first`, where `it` is the aforementioned [Iterable].
///
/// A custom [errorMessage] may be provided.
Future findOne(
[Map params,
String errorMessage = 'No record was found matching the given query.']) {
return index(params).then((result) {
if (result == null) {
throw new AngelHttpException.notFound(message: errorMessage);
} else if (result is Iterable) {
if (result.isEmpty) {
throw new AngelHttpException.notFound(message: errorMessage);
} else {
return result.first;
}
} else {
return result;
}
});
}
/// Retrieves all resources. /// Retrieves all resources.
Future index([Map params]) { Future index([Map params]) {
throw new AngelHttpException.methodNotAllowed(); throw new AngelHttpException.methodNotAllowed();