Skip to content

overwritten _id #23

@flamingo-peacock

Description

@flamingo-peacock

I am getting data over written by a later call.

All calls are from the same function that lives on props in my react-native project. Every call happens in the same way. I am getting a successful return of data from all calls to add.

This is my function, which stores only if offline:

 logIfOnline(eventType, data) {
    if(this.state.isOnline) {
      console.log(eventType, data)
      // will eventually get sent to server
    }
    else {
     // save locally if offline, to later send to server
      console.log('event saved')
      var eventData = {
        eventType,
        data
      }
      DB.EventStore.add(eventData, (added_data) => {
        console.log(added_data)
      })
    }
  }

3 calls, from three different places in app-

this.props.logIfOnline('stopped', time)

this.props.logIfOnline('over written event', time)

this.props.logIfOnline('another event', time)

This is what my log looks like-

I/ReactNativeJS: event saved
I/ReactNativeJS: { eventType: 'stopped',
                   data: Fri Oct 21 2016 16:33:13 GMT-0600 (MDT),
                   _id: 72 }
I/ReactNativeJS: event saved
I/ReactNativeJS: { eventType: 'over written event',
                   data: Fri Oct 21 2016 16:33:15 GMT-0600 (MDT),
                   _id: 73 }
I/ReactNativeJS: event saved
I/ReactNativeJS: { eventType: 'another event',
                   data: Fri Oct 21 2016 16:33:17 GMT-0600 (MDT),
                   _id: 73 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions