2 entries into table

I am entering data into a table, which has a geopoint relation, as well as a relation to another table. But when I do so, Backendless is creating 2 data entries into the table. One with the relation, and one without. How do I make t so that it only creates one entry with both relations?

Here’s my code:

.controller('AgAddCtrl', function($scope, $state, $http) {
  console.log("Agent Add");
  $scope.hotelReg = function() {
    var address = $scope.hName + ',' + $scope.hLocality + ',' + $scope.hCity;
    var latitude;
    var longitude;
    var user = $state.params.user;
    var url = "https://maps.googleapis.com/maps/api/geocode/json?key=AIzaSyCv9qLcpwSqElOvsLVaZNIsY161GU3Y7QY&address=" + address;
      .success(function(data) {
        latitude = data.results[0].geometry.location.lat;
        longitude = data.results[0].geometry.location.lng;
        var hotel = {
          name: $scope.hName,
          locality: $scope.hLocality,
          city: $scope.hCity,
          amenities: $scope.hAmenities,
          total_rooms: $scope.hTotalRooms,
          free_rooms: $scope.hFreeRooms,
          latitude: latitude,
          longitude: longitude,
          agent_email: user.email,
          ___class: "Hotels"
          .then( function( savedObject ) {
          .catch( function( error ) {
              console.log("error upload" + error.message);
        var point = {
          latitude: latitude,
          longitude: longitude,
          metadata: {Hotels: hotel}
        Backendless.Geo.savePoint( point )
         .then( function( savedGeoPoint ) {
           var child = [ user.objectId ];
            .then(function(count) {
              console.log("relation set");
            .catch(function(error) {
              console.log("relation error" + err.message);
           console.log( "geo point saved " + savedGeoPoint.objectId );
         .catch( function( error ) {
           console.log( "error - " + error.message );

      .error( function(error) {
        console.log("error map");



in point metadata you put hotel object without its objectId property, which will return after you save hotel. You should take saved hotel object and put it into point metadata. Then it should work properly for you.


When adding the relation, I am referencing the object ID of the hotel, as shown in this line:


Does this not make sure that the relation is made for that object ID?

Don’t you firstly make Backendless.Data.of(“Hotels”).save(hotel)?