I have these two classes in parse

This is my TestItem class and it has items that are available. Then I have my UserFavorites Class:

It has Items that user have favorited. As you can see Buffalo Waffle Fries and Shrimp Po Boy are in both classes. In UserFavs I have a pointer from the item in UserFav to that item in TestItem so I can match them for a purpose not relevant to this question. My problem is that the items in the class TestItem get deleted and new ones are added daily. So the pointer in testItem is no longer valid. So I can no longer match them. As you can see I manually updated the pointer for Shrimp Po Boy, just to show this. I need some help with my javascript code, that will match the items in TestItem to ones in UserFav. And then update the pointer in UserFav to match the objectId in TestItem class. I hope that makes sense if not ask me to clarify. Also it could be possible that more than one user has favorited the same item so I would need it to update both pointers to TestItem class.
Hers what I am working with so far:
Parse.Cloud.define("updateUserFavPointerToTestItem", function(request, response) {
var TestItem = Parse.Object.extend("TestItem");
var UserFav = Parse.Object.extend("UserFavourite");
var testItemsQuery = new Parse.Query(TestItem);
var userFavoritesQuery = new Parse.Query(UserFav);
testItemsQuery.find().then(function(testItemRes) {
for (var i = 0; i < testItemRes.lenght; i++) {
var item = testItemRes.get('item');
userFavoritesQuery.equalTo('item', item);
userFavoritesQuery.then(function(userFavoritesRes) {
for (var i2 = 0; i2 < userFavoritesRes.length; i2++) {
//update the testItem pointer here
//but this doesnt work, I think its because the query is async
//But I am using .then, so maybe I need some promises?
}
});
}
});
});
Thanks so much for the help in advance!