2017-03-06 14 views
0

你好社區:)我用firebase-> realm實現了很多良好的工作功能。現在我試圖編輯一個結構,並且正在運行最瘋狂的錯誤消息。境界 - 價值不可轉換爲數字

什麼肯定是正確的:

  • 火力地堡發送
  • 數據轉換的數據(例如火力地堡具有「品牌」作爲陣列 - >被轉換成用於境界字符串架構)
  • 當Firebase 更新時出現錯誤
  • 並非每個Firebase內容包含所有字段(例如,就像你能看出來的境界架構的某些領域是可選:真)

場在那裏我也許期待一個問題:

  • 也許它不可能說,ReferentList是可選(或者我實現它錯了):見境界架構常量ReferentsList

我試過

  • 前調試realm.create(境集)結果:每一個數據排在了正確的格式
  • 檢查了所有的輸入值,如果它們是整型,字符串,...

希望有人可以幫助我,因爲我完全停留在這個問題上,並且需要繼續爲我的項目工作。我想知道:

  • 的解決方案,爲什麼還是做
  • 一個posibility調試領域有什麼更好的方式 預先感謝您的時間和幫助:)

錯誤消息:值不能轉換爲數字

網絡連接變基數據結構

  • 「開始」: 「2017-05-15T15:50:00.000Z」
  • 「說明」: 「ABC」,
  • 「端」:「2017-05 -15T16:15:00.000Z 「
  • 」ID「:6,
  • 」語言「:[1],
  • 」位置「:」 L 1。02" ,
  • 「構件」:20,
  • 「指涉」:[1,3],
  • 「寄存器」:真的,
  • 「標題」: 「沉默的聲音」,
  • 「軌道」:6,
  • 「類型」:3,
  • 「品牌」:[1,2,3]

境界模式

const ReferentListSchema = { 
 
    name: 'ReferentList', 
 
    properties: { 
 
     id: { 
 
      type: 'int', 
 
      optional: true 
 
     } 
 
    } 
 
} 
 

 
const LanguageListSchema = { 
 
    name: 'LanguageList', 
 
    properties: { 
 
     id: 'int' 
 
    } 
 
} 
 

 
const EventSchema = { 
 
    name: 'Events', 
 
    primaryKey: 'id', 
 
    properties: { 
 
     id: 'int', 
 
     begin: { 
 
      type: 'date', 
 
      optional: true 
 
     }, 
 
     end: { 
 
      type: 'date', 
 
      optional: true 
 
     }, 
 
     title: 'string', 
 
     description: 'string', 
 
     register: 'bool', 
 
     member: { 
 
      type: 'int', 
 
      optional: true 
 
     }, 
 
     language: { 
 
      type: 'list', 
 
      objectType: 'LanguageList' 
 
     }, 
 
     location: 'string', 
 
     referent: { 
 
      type: 'list', 
 
      objectType: 'ReferentList' 
 
     }, 
 
     type: 'int', 
 
     track: { 
 
      type: 'int', 
 
      optional: true 
 
     }, 
 
     img: { 
 
      type: 'string', 
 
      optional: true 
 
     }, 
 
     brands:{ 
 
      type: 'string', 
 
      optional: true 
 
     } 
 
    } 
 
}

境界設置

set(obj) { 
 
    realm.write(() => { 
 
     if(obj.referent){ 
 
      obj.referent = obj.referent.map(function(id) { 
 
       return {id}; 
 
      }) 
 
     } 
 
     if (obj.language){ 
 
      obj.language = obj.language.map(function(id) { 
 
       return {id}; 
 
      }) 
 
     } 
 
     realm.create('Events', obj, true); 
 
    }); 
 
}

回答

0

解決:! 這個問題通過在firebase上的錯誤數據得到解決。一些日期對象 hasent設置正確。

我如何到了解決方案 當我試圖debugg我繞製成一個try/catch塊中的代碼:

try{ 
 
    realm.create('Events', obj, true); 
 
}catch(error){ 
 
    console.log(obj); 
 
    console.log(error); 
 
}

通過這個調試我找到了正確的數據這是錯誤的。在它向我展示所有對象之前以及之後的錯誤。

我不會關閉這個問題,因爲有機會幫助有同樣問題的人.-