Skip to content

Pass list of dates to cloud code functions #1826

Closed
@ideastouch

Description

@ideastouch

The issue here is similar to the issue reported in #655 and #1697 but in this case the param is a list of dates instead of an one object of type date.
In Parse.com server works perfectly and in Parse-server running locally it is not works.

Test
In order to test this issue I am calling a cloud function checkDateList from my app. and I send two kind of params, first a Object of type Date and second a list of objects each one of type Date. Regarding the first parameter everything goes ok thanks to fix Pass dates to cloud code functions but regarding the second parameter I think that we have a bug.

Software versions

  • Parse-iOS-1.12.0
  • parse server ver 2.2.10.

Function definition

Parse.Cloud.define("checkDateList", function(request, response) {
    //Test of one object of type Date
    console.log('request.params.date: ' + request.params.date)
    var date  = request.params.date
    console.log('date : ' + date)
    console.log('date.getTime(): ' + date.getTime())

    //Test list of object each one of type Date
    console.log('request.params.dateList: ' + request.params.dateList)
    console.log('request.params.dateList[0]: ' + request.params.dateList[0])
    var isoDate = request.params.dateList[0]
    console.log('isoDate : ' + isoDate)
    console.log('isoDate.getTime(): ' + isoDate.getTime)

    if (isoDate.__type == 'Date') {
        var date = new Date(isoDate.iso)
        console.log('date : ' + date)
        console.log('date.getTime(): ' + date.getTime())
     }

Parse Server verbose log

$ VERBOSE=1  npm start

> troupefithrk@3.0.0 start /Users/<my name>/CODE/iDT/TroupeFit/troupefit-server
> node index.js

parse-server-example running on port 1337.
verbose: POST /parse/functions/submitAvailability { host: 'localhost:1337',
  'x-parse-client-version': 'i1.12.0',
  accept: '*/*',
  'x-parse-session-token': 'r:<parse session token>',
  'x-parse-application-id': ':<parse application id>',
  'x-parse-client-key': '<parse client key>',
  'x-parse-installation-id': <'parse installation id>',
  'x-parse-os-version': '9.3 (15E65)',
  'accept-language': 'en-us',
  'accept-encoding': 'gzip, deflate',
  'content-type': 'application/json; charset=utf-8',
  'content-length': '141',
  'user-agent': '<App Product Name>/35 CFNetwork/758.3.15 Darwin/15.4.0',
  connection: 'keep-alive',
  'x-parse-app-build-version': '35',
  'x-parse-app-display-version': '3.1' } {
  "date": {
    "__type": "Date",
    "iso": "2016-05-22T09:00:00.000Z"
  },
  "dateList": [
    {
      "__type": "Date",
      "iso": "2016-05-22T09:00:00.000Z"
    }
  ],
  "trainerId": "WZp1UiepFh"
}
request.params.date: Sun May 22 2016 02:00:00 GMT-0700 (PDT)
date : Sun May 22 2016 02:00:00 GMT-0700 (PDT)
date.getTime(): 1463907600000
request.params.dateList: [object Object]
request.params.dateList[0]: [object Object]
isoDate : [object Object]
isoDate.getTime(): undefined
date : Sun May 22 2016 02:00:00 GMT-0700 (PDT)
date.getTime(): 1463907600000

Result explanation
The parameter request.params.dateList should be a list of Date but instead is a list of objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions