nathanheffley / laravel-watermelon

Easily set up a sync endpoint to support Watermelon DB in your Laravel projects.
MIT License
47 stars 13 forks source link

currently push() method is not working as expected for me is this the case with anyone else as well? #6

Closed bilalswiftsolutions closed 11 months ago

bilalswiftsolutions commented 1 year ago

when data was pushed from local it was not updating watermelon_id column in db. when i start debuging

I see that in package controller i have to get data like this?

 public function push(SyncService $watermelon, Request $request): JsonResponse
    {
        **return response()->json( $request->json()->all());**
        return $watermelon->push($request);
    }

otherwise in SeyncService it was always returned from foreach loop

public function push(Request $request): JsonResponse
    {

        // DB::beginTransaction();

        foreach ($this->models as $name => $class) {

            if (!$request->input($name)) {
                continue;
            }   
 }

this problem is with me only or anyone else is also having this issue? because i can not believe this should happen like this, it must be working for you guys. what am i doing wrong here?

i didn't customized client side functions as well those are as same provided by library

nathanheffley commented 1 year ago

I'm not sure if I understand your issue. The Watermelon ID should not be updated on an existing database row. Do you mean it is not getting set when the row is pushed for the first time and the database row is being created?

nathanheffley commented 1 year ago

Do you use $fillable on your models? You may try adding watermelon_id to that array as well to see if that fixes your issue.

Otherwise, please include the model code that you are using with Watermelon and any other code you may have customized so I can try and recreate the issue.

bilalswiftsolutions commented 1 year ago

actually whole process is being happened through the application. so when the record is created on backend and app pullChanges() at the same time pushSame() same data as new records created which gives error in package

nathanheffley commented 1 year ago

Hmmm yeah it sounds like a bit of an unconventional setup but it's hard to tell without a project that reproduces the issue. If you can supply a code example that demonstrates the issue, I might be able to figure out the issue.

nathanheffley commented 11 months ago

Without a project reproducing the issue I'm not able to help. I hope you found a solution!