This has been an issue with me since way back but it is only now that I am mentioning this.

Whenever I save to MongoDB with data in different data types, I get this error:

Compiling Diet HTML template home.dt...
Compiling Diet HTML template about.dt...
Compiling Diet HTML template contact.dt...
Compiling Diet HTML template showtutor.dt...
Compiling Diet HTML template tutorslist.dt...
Compiling Diet HTML template fortutors.dt...
Compiling Diet HTML template contactedus.dt...
Compiling Diet HTML template edittutor.dt...
Compiling Diet HTML template fortutors.dt...
Compiling Diet HTML template edittutor.dt...
Compiling Diet HTML template showtutor.dt...
Compiling Diet HTML template showtutorratings.dt...
Compiling Diet HTML template contacttutor.dt...
Compiling Diet HTML template contactedtutor.dt...
Compiling Diet HTML template ratetutor.dt...
Compiling Diet HTML template showtutor.dt...
Compiling Diet HTML template showtutor.dt...
Compiling Diet HTML template ratetutor.dt...
Compiling Diet HTML template fortutors.dt...
Compiling Diet HTML template login.dt...
Compiling Diet HTML template login.dt...
Compiling Diet HTML template showtutor.dt...
Compiling Diet HTML template login.dt...
source/store.d(118,13): Error: incompatible types for ((tutor.photo) : (tutor.rating)): 'string' and 'float'
dmd failed with exit code 1.

Here is my code:

void appendTutor(Tutor tutor)
{
	tutordocs.insert
	([
		"email":tutor.email,
		"uname":tutor.uname,
		"password":tutor.password,
		"city":tutor.city,
		"province":tutor.province,
		"country":tutor.country,
		"photo":tutor.photo,
		"rating":tutor.rating
	]);
}

Here is the data:

struct Tutor
{
	string email;
	string uname;
	string password;
	string city;
	string province;
	string country;
	string[] subjects;
	string photo;
	float rating;
	int raters;
}


So my workaround is this:

void appendTutor(Tutor tutor)
{
	tutordocs.insert
	([
		"email":tutor.email,
		"uname":tutor.uname,
		"password":tutor.password,
		"city":tutor.city,
		"province":tutor.province,
		"country":tutor.country,
		"photo":tutor.photo,
	]);
	tutordocs.update(["uname":tutor.uname],["$set": ["rating":tutor.rating]]);
	tutordocs.update(["uname":tutor.uname],["$set": ["raters":tutor.raters]]);
	tutordocs.update(["uname":tutor.uname],["$set": ["subjects":tutor.subjects]]);
}

Is there a more efficient way than calling 'update' after 'insert'?

Thanks!