Hi there,
Can anyone point me in the direction of some documentation or some sample code that I could look at that shows if itâs possible to destroy a record with react-moralis?
I canât seem to find anything on this topic.
Thanks!
Hi there,
Can anyone point me in the direction of some documentation or some sample code that I could look at that shows if itâs possible to destroy a record with react-moralis?
I canât seem to find anything on this topic.
Thanks!
It may work with calling .destroy() on the object returned by a query.
https://docs.moralis.io/moralis-server/database/objects#destroying-objects
did you try .destroy() on the object?
you can also write a cloud function if needed
HeeyâŚwhat if you want to delete an object on the db maybe with reference to the object id or any column.I cant find any example on their documentation.I think you must fetch the object first
`
const { fetch } = useMoralisQuery(âdoctorsâ,(query) => query.equalTo(âobjectIdâ, docDeleteId),[docDeleteId],{ autoFetch: false });
// delete an object in moralis
const deleteDoctor = async () => {
fetch ({
onSuccess: (doc) => {
doc.destroy().then(
(doc) => {
alert("Doctor deleted successfully");
},
(errors) => {
alert("The delete failed");
}
)
},
onError: (error) => {
alert("The object was not retrieved successfully");
},
});
}
`
I have tried these code to delete a doctor object in the db but I face the error of using the "const {fetch} " keyword twice in my code can someone help me out.Should i rename the fetch keyword