Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can autoGenerateObjectIDIfNotExist used with partialUpdateObject or partialUpdateObjects #1412

Open
cmgchess opened this issue Jun 30, 2022 · 2 comments

Comments

@cmgchess
Copy link

cmgchess commented Jun 30, 2022

In the documentation for partialUpdateObjects it is mentioned autoGenerateObjectIDIfNotExist as a parameter. When I tried to use it throws the error

    const obj = {} //without objectID
    
    index
    .partialUpdateObject(obj, {
    //   createIfNotExists: true,
      autoGenerateObjectIDIfNotExist: true
    }).then((objectID)=>{
        console.log(objectID)
    }).catch((e) => {
        console.log(e)
    })
{
  name: 'ApiError',
  message: 'Invalid object ' +
    'attributes:autoGenerateObjectIDIfNotExist ' +
    'near line:1 column:166',
  status: 400,
  transporterStackTrace: [
    {
      request: [Object],
      response: [Object],
      host: [Object],
      triesLeft: 3
    }
  ]
}

I'm I doing something wrong here
Thanks

@Haroenv
Copy link
Contributor

Haroenv commented Jul 4, 2022

I checked the code, and think the documentation is wrong, and partialUpdate doesn't support autoGenerate. Note that it's in general not a good idea to have no handle of what the objectID for a record is, as that means you won't be able to update it in the future, and will have to rely on full index updates, which are less efficient

@cmgchess
Copy link
Author

cmgchess commented Jul 4, 2022

Thanks
I was playing around with the API when I stumbled upon this. Thought I did something wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants