Support Topics Documentation Slack YouTube Blog

Documentation for nodejs


(Mohamad Mohamad Jamil) #1

in this link : “https://backendless.com/docs/js/data_basic_search.html” I tried to use this approach:
var contact = Backendless.Data.of( “Contact” ).findByIdSync( {objectId:“XXXX-XXXX-XXXX-XXXX” } );
but got this error : Backendless.Data.of(<ClassName>).findByIdSync" is deprecated and will be removed in the nearest release. Please use “Backendless.Data.of(<ClassName>).findById” instead of.
And this one : “Using of sync methods is an outdated approach. Please use async methods”;
So if this method is outdated I think it is better to remove it from the documentation.
When I use “findById” instead I get an empty object !? Is there any other way to retrieve an object with a blocking call?


(Stanislaw Grin) #2

Hi Mohamad,

documentation says you should pass and objectId, not an object with objectId. So try this approach:
Backendless.Data.of( “Contact” ).findByIdSync(“XXXX-XXXX-XXXX-XXXX”)

Speaking about blocking and non-blocking call methods, then there is no other way to make a synchronous (blocking) call, except for using the synchronous method - and this is not our limitation, but normal practice when writing applications on JS.
As for removing references to synchronous methods from the documentation, the documentation should cover our entire API. The warnings that are given when using synchronous functions give enough reason to believe that they will be removed from the SDK in the near future. So far, we can not give exact estimations.
Personally I would recommend avoiding the use of synchronous methods and writing code asynchronously.

Regards,
Stanislaw


(Mohamad Mohamad Jamil) #3

Actually I use Asnc. methods. But I just read the documentation and played a bit with that. Anyway, in the documentation, it is : Backendless.Data.of( “Contact” ).findByIdSync( {objectId:“XXXX-XXXX-XXXX-XXXX” } ) As I mentioned above.

Another thing when you read the documentation you will find this code :
Backendless.Data.of( “TABLE-NAME” ).findById( objectId ), and here I understand that I should pass an objectId as arg. to the finById() method.
But if you scroll down you will find in the provided example this code :
Backendless.Data.of( “Contact” ).findById( {objectId:“XXXX-XXXX-XXXX-XXXX” } ) !
Anyway, as I understood that both ways work fine with findById() method.

BTW I use this on : Backendless.Data.of( “Contact” ).findById( {objectId:“XXXX-XXXX-XXXX-XXXX” } )
to reteive an object and it works.
This topic’s not about a bug. Just was a little bit confused while I was reading the documentation.


(Stanislaw Grin) #4

I got you now. I will create a ticket to make this part of the documentation clearer.
Thank you for pointing this out.

Regards,
Stanislaw