Added autoSnakeCaseNames to MapService

This commit is contained in:
Tobe O 2018-02-06 22:24:44 -05:00
parent 333ba32dff
commit 56e1fc62d0
5 changed files with 106 additions and 85 deletions

View file

@ -317,13 +317,6 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="recase">
<value>
<list>
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/recase-1.0.0+1/lib" />
</list>
</value>
</entry>
<entry key="shelf"> <entry key="shelf">
<value> <value>
<list> <list>
@ -498,7 +491,6 @@
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/pub_semver-1.3.2/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/pub_semver-1.3.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/quiver_hashcode-1.0.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/quiver_hashcode-1.0.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/random_string-0.0.1/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/random_string-0.0.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/recase-1.0.0+1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf-0.7.2/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf-0.7.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf_packages_handler-1.0.3/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf_packages_handler-1.0.3/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf_static-0.2.7/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf_static-0.2.7/lib" />

View file

@ -1,11 +1,11 @@
<?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="Response no longer closes if `serialize` is called with an empty string"> <list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/libraries/Dart_Packages.xml" afterPath="$PROJECT_DIR$/.idea/libraries/Dart_Packages.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/libraries/Dart_Packages.xml" afterPath="$PROJECT_DIR$/.idea/libraries/Dart_Packages.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/CHANGELOG.md" afterPath="$PROJECT_DIR$/CHANGELOG.md" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/CHANGELOG.md" afterPath="$PROJECT_DIR$/CHANGELOG.md" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/response_context.dart" afterPath="$PROJECT_DIR$/lib/src/http/response_context.dart" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/map_service.dart" afterPath="$PROJECT_DIR$/lib/src/http/map_service.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/pubspec.yaml" afterPath="$PROJECT_DIR$/pubspec.yaml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/pubspec.yaml" afterPath="$PROJECT_DIR$/pubspec.yaml" />
</list> </list>
<ignored path="$PROJECT_DIR$/.tmp/" /> <ignored path="$PROJECT_DIR$/.tmp/" />
@ -49,27 +49,42 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="true"> <file leaf-file-name="map_service.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/CHANGELOG.md"> <entry file="file://$PROJECT_DIR$/lib/src/http/map_service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="245">
<caret line="94" column="46" lean-forward="true" selection-start-line="94" selection-start-column="46" selection-end-line="94" selection-end-column="46" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="README.md" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/README.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="30"> <first_editor relative-caret-position="0">
<caret line="2" column="13" lean-forward="false" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" /> <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding /> <folding>
<marker date="1506049250000" expanded="true" signature="588:776" ph="{...}" />
</folding>
</first_editor> </first_editor>
<second_editor /> <second_editor />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="map_service.dart" pinned="false" current-in-tab="false"> <file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/src/http/map_service.dart"> <entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state relative-caret-position="15"> <state split_layout="SPLIT">
<caret line="24" column="0" lean-forward="false" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" /> <first_editor relative-caret-position="45">
<folding> <caret line="3" column="45" lean-forward="false" selection-start-line="3" selection-start-column="45" selection-end-line="3" selection-end-column="45" />
<element signature="e#0#20#0" expanded="true" /> <folding />
</folding> </first_editor>
<second_editor />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -132,19 +147,6 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="all.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/all.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="31" column="33" lean-forward="false" selection-start-line="31" selection-start-column="33" selection-end-line="31" selection-end-column="33" />
<folding>
<element signature="e#0#38#0" expanded="true" />
<marker date="1511894754000" expanded="true" signature="1709:1766" ph="{...}" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf> </leaf>
</component> </component>
<component name="FileTemplateManagerImpl"> <component name="FileTemplateManagerImpl">
@ -156,8 +158,6 @@
</component> </component>
<component name="FindInProjectRecents"> <component name="FindInProjectRecents">
<findStrings> <findStrings>
<find>sendRes</find>
<find>handleRequ</find>
<find>sendRespon</find> <find>sendRespon</find>
<find>inject(</find> <find>inject(</find>
<find>sendRe</find> <find>sendRe</find>
@ -186,6 +186,8 @@
<find>cache</find> <find>cache</find>
<find>errorHan</find> <find>errorHan</find>
<find>addStre</find> <find>addStre</find>
<find>((cre)|(upd))atedAt</find>
<find>'((cre)|(upd))atedAt'</find>
</findStrings> </findStrings>
<replaceStrings> <replaceStrings>
<replace>_isClosed</replace> <replace>_isClosed</replace>
@ -206,6 +208,7 @@
<replace>cookie</replace> <replace>cookie</replace>
<replace>req.path</replace> <replace>req.path</replace>
<replace>req.path`</replace> <replace>req.path`</replace>
<replace>autoSnakeCaseNames == false ? $0 : '$1ated_at'</replace>
</replaceStrings> </replaceStrings>
<dirStrings> <dirStrings>
<dir>C:\Users\thosa\Source\Angel\framework\lib</dir> <dir>C:\Users\thosa\Source\Angel\framework\lib</dir>
@ -278,10 +281,10 @@
<option value="$PROJECT_DIR$/test/extension_test.dart" /> <option value="$PROJECT_DIR$/test/extension_test.dart" />
<option value="$PROJECT_DIR$/test/all.dart" /> <option value="$PROJECT_DIR$/test/all.dart" />
<option value="$PROJECT_DIR$/lib/src/http/service.dart" /> <option value="$PROJECT_DIR$/lib/src/http/service.dart" />
<option value="$PROJECT_DIR$/lib/src/http/map_service.dart" />
<option value="$PROJECT_DIR$/lib/src/http/server.dart" /> <option value="$PROJECT_DIR$/lib/src/http/server.dart" />
<option value="$PROJECT_DIR$/pubspec.yaml" />
<option value="$PROJECT_DIR$/lib/src/http/response_context.dart" /> <option value="$PROJECT_DIR$/lib/src/http/response_context.dart" />
<option value="$PROJECT_DIR$/pubspec.yaml" />
<option value="$PROJECT_DIR$/lib/src/http/map_service.dart" />
<option value="$PROJECT_DIR$/CHANGELOG.md" /> <option value="$PROJECT_DIR$/CHANGELOG.md" />
</list> </list>
</option> </option>
@ -370,7 +373,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="RunManager" selected="Dart Test.All Tests (PRODUCTION)"> <component name="RunManager" selected="Dart Test.All Tests">
<configuration name="Chained routes in routing_test.dart" type="DartTestRunConfigurationType" factoryName="Dart Test" nameIsGenerated="true"> <configuration name="Chained routes in routing_test.dart" type="DartTestRunConfigurationType" factoryName="Dart Test" nameIsGenerated="true">
<option name="filePath" value="$PROJECT_DIR$/test/routing_test.dart" /> <option name="filePath" value="$PROJECT_DIR$/test/routing_test.dart" />
<option name="scope" value="GROUP_OR_TEST_BY_NAME" /> <option name="scope" value="GROUP_OR_TEST_BY_NAME" />
@ -672,7 +675,7 @@
<workItem from="1513103483207" duration="18000" /> <workItem from="1513103483207" duration="18000" />
<workItem from="1513103506825" duration="139000" /> <workItem from="1513103506825" duration="139000" />
<workItem from="1517332581856" duration="858000" /> <workItem from="1517332581856" duration="858000" />
<workItem from="1517973177718" duration="223000" /> <workItem from="1517973177718" duration="692000" />
</task> </task>
<task id="LOCAL-00001" summary="Re-designed exception"> <task id="LOCAL-00001" summary="Re-designed exception">
<created>1481237183504</created> <created>1481237183504</created>
@ -1003,11 +1006,18 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1513103639013</updated> <updated>1513103639013</updated>
</task> </task>
<option name="localTasksCounter" value="48" /> <task id="LOCAL-00048" summary="Response no longer closes if `serialize` is called with an empty string">
<created>1517973412941</created>
<option name="number" value="00048" />
<option name="presentableId" value="LOCAL-00048" />
<option name="project" value="LOCAL" />
<updated>1517973412941</updated>
</task>
<option name="localTasksCounter" value="49" />
<servers /> <servers />
</component> </component>
<component name="TestHistory"> <component name="TestHistory">
<history-entry file="All_Tests - 2017.12.12 at 13h 32m 53s.xml"> <history-entry file="All_Tests - 2018.02.06 at 22h 24m 09s.xml">
<configuration name="All Tests" configurationId="DartTestRunConfigurationType" /> <configuration name="All Tests" configurationId="DartTestRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="All_Tests_(PRODUCTION) - 2017.11.28 at 13h 12m 52s.xml"> <history-entry file="All_Tests_(PRODUCTION) - 2017.11.28 at 13h 12m 52s.xml">
@ -1039,7 +1049,7 @@
</history-entry> </history-entry>
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="118259000" /> <option name="totallyTimeSpent" value="118728000" />
</component> </component>
<component name="TodoView"> <component name="TodoView">
<todo-panel id="selected-file"> <todo-panel id="selected-file">
@ -1074,7 +1084,7 @@
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32905984" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32905984" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4002849" sideWeight="0.4964476" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.4002849" sideWeight="0.4964476" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.48005697" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.48005697" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2023166" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2023166" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
@ -1097,7 +1107,7 @@
<option name="myLimit" value="2678400000" /> <option name="myLimit" value="2678400000" />
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="1.0.6+2" /> <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<MESSAGE value="Added RequestContext.accepts" /> <MESSAGE value="Added RequestContext.accepts" />
<MESSAGE value="Swapped to angel_model" /> <MESSAGE value="Swapped to angel_model" />
<MESSAGE value="1.0.7+2" /> <MESSAGE value="1.0.7+2" />
@ -1122,7 +1132,8 @@
<MESSAGE value="Patched _matchesId, bump to 1.1.0+1" /> <MESSAGE value="Patched _matchesId, bump to 1.1.0+1" />
<MESSAGE value="Patched handleAngelHttpException, bump to 1.1.0+2" /> <MESSAGE value="Patched handleAngelHttpException, bump to 1.1.0+2" />
<MESSAGE value="Patched ResponseContext#isOpen, bump to 1.1.0+3" /> <MESSAGE value="Patched ResponseContext#isOpen, bump to 1.1.0+3" />
<option name="LAST_COMMIT_MESSAGE" value="Patched ResponseContext#isOpen, bump to 1.1.0+3" /> <MESSAGE value="Response no longer closes if `serialize` is called with an empty string" />
<option name="LAST_COMMIT_MESSAGE" value="Response no longer closes if `serialize` is called with an empty string" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager /> <breakpoint-manager />
@ -1281,16 +1292,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="210">
<caret line="14" column="24" lean-forward="false" selection-start-line="14" selection-start-column="24" selection-end-line="14" selection-end-column="24" />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/di_test.dart"> <entry file="file://$PROJECT_DIR$/test/di_test.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30"> <state relative-caret-position="30">
@ -1460,14 +1461,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="7" column="13" lean-forward="true" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/server.dart"> <entry file="file://$PROJECT_DIR$/lib/src/http/server.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1481"> <state relative-caret-position="1481">
@ -1478,16 +1471,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/map_service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15">
<caret line="24" column="0" lean-forward="false" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/response_context.dart"> <entry file="file://$PROJECT_DIR$/lib/src/http/response_context.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="371"> <state relative-caret-position="371">
@ -1496,11 +1479,42 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="315">
<caret line="21" column="23" lean-forward="false" selection-start-line="21" selection-start-column="23" selection-end-line="21" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/map_service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="245">
<caret line="94" column="46" lean-forward="true" selection-start-line="94" selection-start-column="46" selection-end-line="94" selection-end-column="46" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<marker date="1506049250000" expanded="true" signature="588:776" ph="{...}" />
</folding>
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<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="30"> <first_editor relative-caret-position="45">
<caret line="2" column="13" lean-forward="false" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" /> <caret line="3" column="45" lean-forward="false" selection-start-line="3" selection-start-column="45" selection-end-line="3" selection-end-column="45" />
<folding /> <folding />
</first_editor> </first_editor>
<second_editor /> <second_editor />

View file

@ -1,6 +1,7 @@
# 1.1.1 # 1.1.1
* `ResponseContext` no longer automatically closes if `serializer` returns an * `ResponseContext` no longer automatically closes if `serializer` returns an
empty string. empty string.
* Added `autoSnakeCaseNames` to `MapService`.
# 1.1.0+3 # 1.1.0+3
* Modified `ResponseContext#isOpen` to also return `false` if streaming is being used. * Modified `ResponseContext#isOpen` to also return `false` if streaming is being used.

View file

@ -15,14 +15,24 @@ class MapService extends Service {
/// If set to `true` (default), then the service will manage an `id` string and `createdAt` and `updatedAt` fields. /// If set to `true` (default), then the service will manage an `id` string and `createdAt` and `updatedAt` fields.
final bool autoIdAndDateFields; final bool autoIdAndDateFields;
/// If set to `true` (default), then the keys `created_at` and `updated_at` will automatically be snake_cased.
final bool autoSnakeCaseNames;
final List<Map<String, dynamic>> items = []; final List<Map<String, dynamic>> items = [];
MapService( MapService(
{this.allowRemoveAll: false, {this.allowRemoveAll: false,
this.allowQuery: true, this.allowQuery: true,
this.autoIdAndDateFields: true}) this.autoIdAndDateFields: true,
this.autoSnakeCaseNames: true})
: super(); : super();
String get createdAtKey =>
autoSnakeCaseNames == false ? 'createdAt' : 'created_at';
String get updatedAtKey =>
autoSnakeCaseNames == false ? 'updatedAt' : 'updated_at';
bool Function(Map) _matchesId(id) { bool Function(Map) _matchesId(id) {
return (Map item) { return (Map item) {
if (item['id'] == null) if (item['id'] == null)
@ -72,8 +82,8 @@ class MapService extends Service {
if (autoIdAndDateFields == true) { if (autoIdAndDateFields == true) {
result result
..['id'] = items.length.toString() ..['id'] = items.length.toString()
..['createdAt'] = now ..[autoSnakeCaseNames == false ? 'createdAt' : 'created_at'] = now
..['updatedAt'] = now; ..[autoSnakeCaseNames == false ? 'updatedAt' : 'updated_at'] = now;
} }
items.add(result); items.add(result);
return result; return result;
@ -90,7 +100,10 @@ class MapService extends Service {
var item = await read(id); var item = await read(id);
var result = item..addAll(data); var result = item..addAll(data);
if (autoIdAndDateFields == true) result..['updatedAt'] = new DateTime.now(); if (autoIdAndDateFields == true)
result
..[autoSnakeCaseNames == false ? 'updatedAt' : 'updated_at'] =
new DateTime.now();
return result; return result;
} }
@ -112,8 +125,10 @@ class MapService extends Service {
if (autoIdAndDateFields == true) { if (autoIdAndDateFields == true) {
result result
..['id'] = id?.toString() ..['id'] = id?.toString()
..['createdAt'] = old['createdAt'] ..[autoSnakeCaseNames == false ? 'createdAt' : 'created_at'] =
..['updatedAt'] = new DateTime.now(); old[autoSnakeCaseNames == false ? 'createdAt' : 'created_at']
..[autoSnakeCaseNames == false ? 'updatedAt' : 'updated_at'] =
new DateTime.now();
} }
items.add(result); items.add(result);
return result; return result;

View file

@ -20,7 +20,6 @@ dependencies:
mime: ^0.9.3 mime: ^0.9.3
pool: ^1.0.0 pool: ^1.0.0
random_string: ^0.0.1 random_string: ^0.0.1
recase: ^1.0.0
tuple: ^1.0.0 tuple: ^1.0.0
dev_dependencies: dev_dependencies:
mock_request: ^1.0.0 mock_request: ^1.0.0