Hello, I have a question.
const book = await authClient (token) .query (
q.Create (q.Collection ('Book'), (
data: {
title,
author,
creator_id,
}
})
);
I am processing it. I need creator_id. However, I get the following error: document is not unique. How can I change this? I don’t want unique. Thanks
@fsuaterdogan You must have defined an Index with unique set to true. Please update that Index with unique: false
.
@Jay-Fauna its giving
[BadRequest: instance not unique] {
description: 'document is not unique.',
requestResult: RequestResult {
method: 'POST',
path: '',
query: null,
requestRaw: '{"create":{"collection":"Book"},"params":{"object":{"data":{"object":{"title":"asdfas","author":"dfasdf","image":"asdfsad","desc":"asdfasd","price":2,"creator_id":"289413191345111559","creator_email":"ferhatsuat@yandex.com","abstract":"asdfasdf","pages":"324"}}}}}',
requestContent: Expr { raw: [Object] },
responseRaw: '{"errors":[{"position":["create"],"code":"instance not unique","description":"document is not unique."}]}',
responseContent: { errors: [Array] },
statusCode: 400,
responseHeaders: {
connection: 'keep-alive',
'content-length': '105',
'content-type': 'application/json;charset=utf-8',
'x-byte-read-ops': '0',
'x-byte-write-ops': '0',
'x-compute-ops': '1',
'x-faunadb-build': '21.02.02.rc9-fc00d62',
'x-query-bytes-in': '264',
'x-query-bytes-out': '105',
'x-query-time': '246',
'x-read-ops': '0',
'x-storage-bytes-read': '1019',
'x-storage-bytes-write': '0',
'x-txn-retries': '0',
'x-txn-time': '1613836470120830',
'x-write-ops': '0'
},
startTime: 1613836469695,
endTime: 1613836470321
}
}
Jay’s answer is correct, could you look into your indexes and look for an index that has a ‘unique’ flag set or please show us the indexes you have configured.