Livedata returned by Room won't be triggered after GC
Date : March 29 2020, 07:55 AM
|
Django - Room model needs to have a selection of many room types. One room must have at least one room type from the pre
Tag : django , By : Kilimanjaro
Date : March 29 2020, 07:55 AM
I wish this help you You should change your Room model. Also your property will be deleted if the user is deleted. Are you sure you want this? class Room(models.Model):
property = models.ForeignKey(Property)
name = models.CharField(max_length=250)
description = models.TextField(max_length=800)
image = models.ImageField(upload_to='room_images/', blank=False)
bar_rate = models.IntegerField(default=0, blank=False)
SGL = 1
TWN = 2
DBL = 3
TRPL = 4
STND = 5
DLX = 6
EXET = 7
SPR = 8
SPR = 9
JS = 10
ONEBDR = 11
TWOBDR = 12
THREEBDR = 13
FOURBDR = 14
FIVEBDR = 15
SIXBDR = 16
SEVENBDR = 17
ROOM_TYPES = (
(SGL, 'Single'),
(TWN, 'Twin'),
(DBL, 'Double'),
(TRPL, 'Triple'),
(STND, 'Standard'),
(DLX, 'Deluxe'),
(EXET, 'Executive'),
(SPR, 'Superior'),
(JS, 'Junior Suite'),
(ONEBDR, 'One Bedroom'),
(TWOBDR, 'Two Bedroom'),
(THREEBDR, 'Three Bedroom'),
(FOURBDR, 'Four Bedroom'),
(FIVEBDR, 'Five Bedroom'),
(SIXBDR, 'Six Bedroom'),
(SEVENBDR, 'Seven Bedroom'),
)
room_type = models.IntegerField(choices=ROOM_TYPES)
max_occupancy = models.IntegerField(default=1, blank=False)
extra_beds = models.IntegerField(default=0, blank=True)
price_per_exra_bed = models.IntegerField(default=0, blank=True)
is_breakfast_included = models.BooleanField(default=False)
room_type_quantity = models.IntegerField(default=0, blank=False)
def __str__(self):
return self.name
|
(Room Database)fields which are not returned by the query error
Tag : java , By : hyperNURb
Date : March 29 2020, 07:55 AM
wish of those help You are trying to tell Room to build a ClassEntity object from a single String (for each query). It is saying that it cannot safely do this. The fix is to return a List as oppsed to a List.@androidx.room.Dao
public interface Dao {
@Query("SELECT monday FROM ClassEntity WHERE id_of_a_group = :id")
List<String> findFromMonday(String id);
@Query("SELECT tuesday FROM ClassEntity WHERE id_of_a_group = :id")
List<String> findFromTuesday(String id);
@Query("SELECT wednesday FROM ClassEntity WHERE id_of_a_group = :id")
List<String> findFromWednesday(String id);
@Query("SELECT thursday FROM ClassEntity WHERE id_of_a_group = :id")
List<String> findFromThursday(String id);
@Query("SELECT friday FROM ClassEntity WHERE id_of_a_group = :id")
List<String> findFromFriday(String id);
@Query("SELECT id_of_a_group FROM ClassEntity")
List<String> getIdOfAllGroups();
@Insert
void insert(ClassEntity group);
@Update
void update(ClassEntity group);
@Delete
void delete(ClassEntity group);
}
public abstract Array[] getIdOfAllGroups();
@Query("SELECT count() FROM ClassEntity")
int getItemsInDatabase();
database = Room.databaseBuilder(this, Database.class, "database")
.allowMainThreadQueries()
.build();
Log.d("ITEMSINDB",String.valueOf(database.classDao().getItemsInDatabase()));
if (database.classDao().getItemsInDatabase() < 1) {
ClassEntity myClassEntity = new ClassEntity();
myClassEntity.id_of_a_group = "myfirstid";
myClassEntity.monday = "something on Monday";
myClassEntity.tuesday = "on Tuesday";
myClassEntity.wednesday = "another on Wed";
myClassEntity.thursday = "this on Thurs";
myClassEntity.friday = "TGIF";
database.classDao().insert(myClassEntity);
}
Log.d("ITEMSINDB",String.valueOf(database.classDao().getItemsInDatabase()));
2020-01-07 09:48:30.251 D/ITEMSINDB: 0
2020-01-07 09:48:30.254 D/ITEMSINDB: 1
2020-01-07 09:57:03.217 D/ITEMSINDB: 1
2020-01-07 09:57:03.218 D/ITEMSINDB: 1
List<String> mygroups = database.classDao().getIdOfAllGroups();
@Query("SELECT count() > 0 FROM ClassEntity WHERE id_of_a_group = :id")
boolean doesGroupExist(String id);
String test1 = "this group doesn not exists";
if (!database.classDao().doesGroupExist(test1)) {
Log.d("GROUPLOOKUPRESULT","Group " + test1 + " Not located.");
} else {
Log.d("GROUPLOOKUPRESULT","Group " + test1 + " Located.");
}
String test2 = "myfirstid";
if (database.classDao().doesGroupExist(test2)) {
Log.d("GROUPLOOKUPRESULT","Group " + test2 + " Located.");
} else {
Log.d("GROUPLOOKUPRESULT","Group " + test2 + " Not Located.");
}
2020-01-07 10:17:49.201 D/GROUPLOOKUPRESULT: Group this group doesn not exists Not located.
2020-01-07 10:17:49.201 D/GROUPLOOKUPRESULT: Group myfirstid Located.
|
value returned from SQLite using Room Persistence is not being assigned to MutableLiveData
Date : March 29 2020, 07:55 AM
this one helps. Inside your activity sumOfAllWeight is not observable. So it's not reflect when changes outside observer. Check with below code: mFooViewModel.getSumOfAllWeight().observe(
this,
Observer {
tv_sum_lbl.text = "$it - KG(s)" // Now check value here
}
)
|
Socket.io joining a room registers the room but only joins an empty string room
Date : March 29 2020, 07:55 AM
|