python (65.2k questions)
javascript (44.3k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (13k questions)
Partial unique index in Postgres to ensure existence of a row that satisfies the constraint?
I have a users table, a teams table and a users_teams table.
I am looking for a way in postgres to do the following:
I want to ensure that a user always has a default team, a record with is_default tr...
bencex
Votes: 0
Answers: 1
Create a row which does not violate a unique index
I have a table with Id, AccountId, PeriodId, and Comment. I have a unique index for (AccountId, PeriodId). I want to create such a row which does not violate the unique index. AccountId and PeriodId c...

Istvan Heckl
Votes: 0
Answers: 1
Mongoose unique sparse index in nested array
For my project, I am trying to allow users to use multiple emails or phone numbers.
My schema look like this:
const username = {
type: String,
trim: true,
sparse: true,
unique: true,
...
francis
Votes: 0
Answers: 0
How to apply unique constraints only on specific fields in MongoDB
I have a User schema as follows(JavaScript):-
const userSchema = mongoose.Schema({
name: {
type: String,
required: [true, "User must have a name."]
},
password: {...
Poseidon Broger
Votes: 0
Answers: 1