Setting up partition key for schema

I am trying to add a new schema to my app, but I keep getting this error “schema for namespace (AppName.User) must include partition key “pair””. Any ideas about how I can resolve this?

{ "properties": { "_id": { "bsonType": "string" }, "_partition": { "bsonType": "string" }, "memberOf": { "bsonType": "array", "items": { "bsonType": "object", "properties": { "name": { "bsonType": "string" }, "partition": { "bsonType": "string" } }, "title": "Project" } }, "name": { "bsonType": "string" } }, "required": [ "_id", "_partition", "name" ], "title": "User" }

Hi @Abene_Tester. Welcome to the forums!

I expanded the model out a bit to make it easier to see:

I’m not sure exactly, but since you didn’t append partition with the _ in your Project object, it might be looking for _partition and not finding it.

I’d try to update the "partition" in your Project properties to be "_partition"

Thank your for the help! I went to my sync configuration and found that I set the partition key as “pair”. After reconfiguring the name for partition key, everything works fine now.

1 Like