Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

298
Visualizações
Realm JS/ React-Native: How to rename a table/entity

context: I have an app for both iOS and Android; where the iOS version is native and the Android version is in React-Native. I started with two individual object schemes, but now I want to modify the Android (React-Native) scheme so that all entities are equal to my iOS version. I want to do this so I can easily exchange database files while testing, and because I want to implement cross-platform cloud sync.

What's happening

Say I have these two entities:

  static schema: Realm.ObjectSchema = {
    name: 'DBGame',
    primaryKey: 'id',
    properties: {
      id: 'string',
      players: 'DBPlayer[]',
    },
  };

  static schema: Realm.ObjectSchema = {
    name: 'DBPlayer',
    primaryKey: 'id',
    properties: {
      id: 'string',
      games: {type: 'linkingObjects', objectType: 'DBGame', property: 'players'},
    },
  };

If I want to rename these entities from DBGame & DBPlayer to RSGame and RSPlayer, I would:

  • up my schema version number
  • add a migration function when opening the realm

.. and then what? When I rename the schema names, Realm will fail to open at all since it can't find a table with the new schema names (which makes sense, because they're not migrated yet).

Question Right now it seems like the only way to rename Realm tables in JS is to just create new schema's besides the old ones and keep them all alive until ALL USERS have migrated. However, this seems ugly and hacky.

What is the proper way to rename tables/entities in Realm JS / Realm React-Native?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

A couple of things:

Realm Migrations do not apply to Realm Sync - they are for local only Realms.

At the moment, the process for Realm Sync is to update your code, delete all local data and allow Realm Sync to re-download all of the data.

The other thing is that Realm has no tables - Realm is an Object database, not SQL. There are only objects, so once your local data is deleted and Objects updated, you are all set.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda