Enforce uniqueness in thinky (rethinkdb)

129 Views Asked by At

In the thinky.io docs the following pattern is described to enforce uniqueness:

var Model = thinky.createModel("user",
    name: type.string()
}, {
    pk: "name"
});

Where the name property is assigned to the primary key.

Is this a typo? That is, should it read:

var Model = thinky.createModel("user", {
    name: type.string()
}, {
    pk: "name"
});

Also for anyone familiar with thinky who has used this pattern before, is there a similar way of assigning uniqueness as it is done in mongoose (mongodb):

const userSchema = new Schema({
    name: { type: String, unique: true }
});

Thanks.

Update: link to the docs https://thinky.io/documentation/faq/

1

There are 1 best solutions below

0
On BEST ANSWER

Yes, definitely a typo as the first example is not valid.