This is how my firebase database looks like:

I am using firebase realtime database. At the moment all users can create a post which is good. All users can delete their post if they are the owner (which is what i want), when a user is editing a post that he does not own, it creates a duplicate of that post with the new updated information.
They are not editing the original post they are duplicating it under their uid. What are the rules so they can't duplicate the post?
those are my rules:
{
"rules": {
".read": true,
".write": "auth != null",
"posts":{
"$uid":{
".write": "auth != null && auth.uid == $uid"
}
}
}
}
this is my code
const [currentUser, setCurrentUser] = useState();
const [id, setId] = useState("");
const [show, setShow] = useState(false);
useEffect(() => {
const unsubscribe = auth.onAuthStateChanged(async (userAuth) => {
if (userAuth) {
const userRef = await createUserProfileDocument(userAuth);
userRef.on("value", (snapShot) => {
setCurrentUser({ key: snapShot.key, ...snapShot.val() });
});
}
if (setCurrentUser(userAuth)) {
} else if (!userAuth && typeof window !== "undefined") {
return null;
}
const uid = userAuth.uid;
console.log(uid);
setId(uid);
});
return unsubscribe;
}, []);
const postKey = props.farm.postKey;
console.log(id);
const DeletePost = () => {
getFirebase()
.database()
.ref(`Users/Posts/`)
.child(`${id}`)
.child(`${postKey}`)
.remove();
};
const updatePost = (e) => {
e.preventDefault();
const obj = {
...values,
};
const postKey = props.farm.postKey;
getFirebase()
.database()
.ref(`Users/Posts/`)
.child(`${id}`)
.child(`${postKey}`)
.update(obj, (err) => {
if (err) console.log(err);
});
};