Mongoose Subdocuments in Nest.js

I dug into the source code and learned how Schema class is converted by the SchemaFactory.createForClass method. Well so how it works? 1. Take a look at this example below: @Schema() export class Cat extends Document { @Prop() name: string; } export const catSchema = SchemaFactory.createForClass(Cat); Basically, when you do SchemaFactory.createForClass(Cat) Nest will convert the … Read more

Database schema for chat: private and group

Your schema looks perfectly fine, you might see the others (including myself today) came with more or less the same structure before (Storing messages of different chats in a single database table, Database schema for one-to-one and group chat, Creating a threaded private messaging system like facebook and gmail). I’d really like to note that … Read more

Mongoose: extending schemas

Mongoose 3.8.1 now has support for Discriminators. A sample, from here: http://mongoosejs.com/docs/api.html#model_Model.discriminator function BaseSchema() { Schema.apply(this, arguments); this.add({ name: String, createdAt: Date }); } util.inherits(BaseSchema, Schema); var PersonSchema = new BaseSchema(); var BossSchema = new BaseSchema({ department: String }); var Person = mongoose.model(‘Person’, PersonSchema); var Boss = Person.discriminator(‘Boss’, BossSchema);

Why do we specify namespace in android xml file?

From developer.android.com xmlns:android Defines the Android namespace. This attribute should always be set to “http://schemas.android.com/apk/res/android”. xmlns:android is for identification that this xml is used for android, not for other function. Namespaces uniquely identify code/libraries. If I write an api that uses all the same names and such as the android api the only way to … Read more