Browse Source

Entity renaming

pull/1/head
Tim Glasgow 2 years ago
parent
commit
f61d9924b8
  1. 2
      squarenotsquare/src/realm/entities/Score.js
  2. 2
      squarenotsquare/src/realm/entities/System.js
  3. 2
      squarenotsquare/src/realm/entities/User.js
  4. 4
      squarenotsquare/src/realm/migrations/MigrateV1.js
  5. 2
      squarenotsquare/src/realm/repos/ScoreRepo.js
  6. 8
      squarenotsquare/src/realm/repos/SystemRepo.js
  7. 2
      squarenotsquare/src/realm/repos/UserRepo.js

2
squarenotsquare/src/realm/entities/Score.js

@ -1,4 +1,4 @@
export const Score = { export const ScoreEntity = {
name: 'Score', name: 'Score',
primaryKey: 'id', primaryKey: 'id',
properties: { properties: {

2
squarenotsquare/src/realm/entities/System.js

@ -1,4 +1,4 @@
export const System = { export const SystemEntity = {
name: 'System', name: 'System',
primaryKey: 'id', primaryKey: 'id',
properties: { properties: {

2
squarenotsquare/src/realm/entities/User.js

@ -1,4 +1,4 @@
export const User = { export const UserEntity = {
name: 'User', name: 'User',
primaryKey: 'id', primaryKey: 'id',
properties: { properties: {

4
squarenotsquare/src/realm/migrations/MigrateV1.js

@ -1,10 +1,10 @@
import {System} from '../entities/System'; import {SystemEntity} from '../entities/System';
import 'react-native-get-random-values'; import 'react-native-get-random-values';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
export function migratev1(oldRealm, newRealm) { export function migratev1(oldRealm, newRealm) {
if (oldRealm.schemaVersion === 0) { if (oldRealm.schemaVersion === 0) {
newRealm.create(System.name, { newRealm.create(SystemEntity.name, {
id: uuidv4(), id: uuidv4(),
key: 'username', key: 'username',
value: 'changeme' value: 'changeme'

2
squarenotsquare/src/realm/repos/ScoreRepo.js

@ -1,4 +1,4 @@
import {Score} from '../entities/Score'; import {ScoreEntity} from '../entities/Score';
import 'react-native-get-random-values'; import 'react-native-get-random-values';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';

8
squarenotsquare/src/realm/repos/SystemRepo.js

@ -1,4 +1,4 @@
import {System} from '../entities/System'; import {SystemEntity} from '../entities/System';
import 'react-native-get-random-values'; import 'react-native-get-random-values';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
@ -10,7 +10,7 @@ export default class SystemRepo {
} }
getAllSystemValues = () => { getAllSystemValues = () => {
let system = this.realmDB.objects(System.name); let system = this.realmDB.objects(SystemEntity.name);
let systemValues = {}; let systemValues = {};
system.forEach((row) => { system.forEach((row) => {
systemValues[row.key] = row.value; systemValues[row.key] = row.value;
@ -32,7 +32,7 @@ export default class SystemRepo {
} }
this.realmDB.write(() => { this.realmDB.write(() => {
this.realmDB.create( this.realmDB.create(
System.name, SystemEntity.name,
{ {
id: sysID, id: sysID,
key: sysKey, key: sysKey,
@ -53,7 +53,7 @@ export default class SystemRepo {
}; };
getSystemKeyValue = (key) => { getSystemKeyValue = (key) => {
let row = this.realmDB.objects(System.name).filtered('key = $0', key); let row = this.realmDB.objects(SystemEntity.name).filtered('key = $0', key);
if (row.length === 1) { if (row.length === 1) {
return {id: row[0].id, value: row[0].value}; return {id: row[0].id, value: row[0].value};
} else if (row.length > 1) { } else if (row.length > 1) {

2
squarenotsquare/src/realm/repos/UserRepo.js

@ -1,4 +1,4 @@
import {User} from '../entities/User'; import {UserEntity} from '../entities/User';
import 'react-native-get-random-values'; import 'react-native-get-random-values';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';

Loading…
Cancel
Save