MySQL and MongoDB promise recursion