You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-40
Original file line number
Diff line number
Diff line change
@@ -103,7 +103,7 @@ Edit `datasources.json` to add any other additional properties that you require.
103
103
<td>Enable this option to deal with big numbers (BIGINT and DECIMAL columns) in the database. Default is false.</td>
104
104
</tr>
105
105
<tr>
106
-
<td>timezone</td>
106
+
<td>timeZone</td>
107
107
<td>String</td>
108
108
<td>The timezone used to store local dates. Default is ‘local’.</td>
109
109
</tr>
@@ -280,45 +280,6 @@ Example:
280
280
}
281
281
```
282
282
283
-
### Date types
284
-
285
-
For TIMESTAMP and DATE types, use the `dateType` option to specify custom type. By default it is DATETIME.
286
-
287
-
Example:
288
-
289
-
```javascript
290
-
{ startTime :
291
-
{ type:Date,
292
-
dataType:'timestamp'
293
-
}
294
-
}
295
-
```
296
-
297
-
**Note:** When quering a `DATE` type, please be aware that values sent to the server via REST API call will be converted to a Date object using the server timezone. Then, only `YYYY-MM-DD` part of the date will be used for the SQL query.
298
-
299
-
For example, if the client and the server is in GMT+2 and GMT -2 timezone respectively. Performing the following operation at `02:00 on 2016/11/22` from the client side:
300
-
301
-
```javascript
302
-
var products =Product.find({where:{expired:newDate(2016,11,22)}});
303
-
```
304
-
305
-
will result in the REST URL to look like: `/api/Products/?filter={"where":{"expired":"2016-12-21T22:00:00Z"}}` and the SQL will be like this:
306
-
307
-
```SQL
308
-
SELECT*FROM Product WHERE expired ='2016-12-21'
309
-
```
310
-
which is not correct.
311
-
312
-
**Solution:** The workaround to avoid such edge case boundaries with timezones is to use the `DATE` type field as a **_string_** type in the LoopBack model definition.
313
-
314
-
```javascript
315
-
{ birthday :
316
-
{ type:String,
317
-
dataType:'date'
318
-
}
319
-
}
320
-
```
321
-
322
283
### Other types
323
284
324
285
Convert String / DataSource.Text / DataSource.JSON to the following MySQL types:
@@ -351,6 +312,18 @@ Example:
351
312
}
352
313
```
353
314
315
+
Convert JSON Date types to datetime or timestamp
316
+
317
+
Example:
318
+
319
+
```javascript
320
+
{ startTime :
321
+
{ type:Date,
322
+
dataType:'timestamp'
323
+
}
324
+
}
325
+
```
326
+
354
327
### Enum
355
328
356
329
Enums are special. Create an Enum using Enum factory:
0 commit comments