suparisma 1.0.12 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generators/coreGenerator.js +21 -15
- package/package.json +1 -1
|
@@ -1392,6 +1392,8 @@ export function createSuparismaHook<
|
|
|
1392
1392
|
/**
|
|
1393
1393
|
* Create a new record with the provided data.
|
|
1394
1394
|
* Default values from the schema will be applied if not provided.
|
|
1395
|
+
* NOTE: This operation does NOT immediately update the local state.
|
|
1396
|
+
* The state will be updated when the realtime INSERT event is received.
|
|
1395
1397
|
*
|
|
1396
1398
|
* @param data - The data to create the record with
|
|
1397
1399
|
* @returns A promise with the created record or error
|
|
@@ -1464,8 +1466,8 @@ export function createSuparismaHook<
|
|
|
1464
1466
|
|
|
1465
1467
|
if (error) throw error;
|
|
1466
1468
|
|
|
1467
|
-
//
|
|
1468
|
-
|
|
1469
|
+
// DO NOT UPDATE LOCAL STATE HERE - Let realtime INSERT event handle it
|
|
1470
|
+
console.log('✅ Created ' + tableName + ' record, waiting for realtime INSERT event to update state');
|
|
1469
1471
|
|
|
1470
1472
|
// Return created record
|
|
1471
1473
|
return { data: result?.[0] as TWithRelations, error: null };
|
|
@@ -1476,10 +1478,12 @@ export function createSuparismaHook<
|
|
|
1476
1478
|
} finally {
|
|
1477
1479
|
setLoading(false);
|
|
1478
1480
|
}
|
|
1479
|
-
}, [
|
|
1481
|
+
}, []);
|
|
1480
1482
|
|
|
1481
1483
|
/**
|
|
1482
1484
|
* Update an existing record identified by a unique identifier.
|
|
1485
|
+
* NOTE: This operation does NOT immediately update the local state.
|
|
1486
|
+
* The state will be updated when the realtime UPDATE event is received.
|
|
1483
1487
|
*
|
|
1484
1488
|
* @param params - Object containing the identifier and update data
|
|
1485
1489
|
* @returns A promise with the updated record or error
|
|
@@ -1541,10 +1545,8 @@ export function createSuparismaHook<
|
|
|
1541
1545
|
|
|
1542
1546
|
if (error) throw error;
|
|
1543
1547
|
|
|
1544
|
-
//
|
|
1545
|
-
|
|
1546
|
-
// updates can sometimes affect filtering based on updated values
|
|
1547
|
-
setTimeout(() => fetchTotalCount(), 0);
|
|
1548
|
+
// DO NOT UPDATE LOCAL STATE HERE - Let realtime UPDATE event handle it
|
|
1549
|
+
console.log('✅ Updated ' + tableName + ' record, waiting for realtime UPDATE event to update state');
|
|
1548
1550
|
|
|
1549
1551
|
// Return updated record
|
|
1550
1552
|
return { data: data?.[0] as TWithRelations, error: null };
|
|
@@ -1555,10 +1557,12 @@ export function createSuparismaHook<
|
|
|
1555
1557
|
} finally {
|
|
1556
1558
|
setLoading(false);
|
|
1557
1559
|
}
|
|
1558
|
-
}, [
|
|
1560
|
+
}, []);
|
|
1559
1561
|
|
|
1560
1562
|
/**
|
|
1561
1563
|
* Delete a record by its unique identifier.
|
|
1564
|
+
* NOTE: This operation does NOT immediately update the local state.
|
|
1565
|
+
* The state will be updated when the realtime DELETE event is received.
|
|
1562
1566
|
*
|
|
1563
1567
|
* @param where - The unique identifier to delete the record by
|
|
1564
1568
|
* @returns A promise with the deleted record or error
|
|
@@ -1608,8 +1612,8 @@ export function createSuparismaHook<
|
|
|
1608
1612
|
|
|
1609
1613
|
if (error) throw error;
|
|
1610
1614
|
|
|
1611
|
-
//
|
|
1612
|
-
|
|
1615
|
+
// DO NOT UPDATE LOCAL STATE HERE - Let realtime DELETE event handle it
|
|
1616
|
+
console.log('✅ Deleted ' + tableName + ' record, waiting for realtime DELETE event to update state');
|
|
1613
1617
|
|
|
1614
1618
|
// Return the deleted record
|
|
1615
1619
|
return { data: recordToDelete as TWithRelations, error: null };
|
|
@@ -1620,10 +1624,12 @@ export function createSuparismaHook<
|
|
|
1620
1624
|
} finally {
|
|
1621
1625
|
setLoading(false);
|
|
1622
1626
|
}
|
|
1623
|
-
}, [
|
|
1627
|
+
}, []);
|
|
1624
1628
|
|
|
1625
1629
|
/**
|
|
1626
1630
|
* Delete multiple records matching the filter criteria.
|
|
1631
|
+
* NOTE: This operation does NOT immediately update the local state.
|
|
1632
|
+
* The state will be updated when realtime DELETE events are received for each record.
|
|
1627
1633
|
*
|
|
1628
1634
|
* @param params - Query parameters for filtering records to delete
|
|
1629
1635
|
* @returns A promise with the count of deleted records or error
|
|
@@ -1633,7 +1639,7 @@ export function createSuparismaHook<
|
|
|
1633
1639
|
* const result = await users.deleteMany({
|
|
1634
1640
|
* where: { active: false }
|
|
1635
1641
|
* });
|
|
1636
|
-
* console.log(
|
|
1642
|
+
* console.log('Deleted ' + result.count + ' inactive users');
|
|
1637
1643
|
*
|
|
1638
1644
|
* @example
|
|
1639
1645
|
* // Delete all records (use with caution!)
|
|
@@ -1677,8 +1683,8 @@ export function createSuparismaHook<
|
|
|
1677
1683
|
|
|
1678
1684
|
if (deleteError) throw deleteError;
|
|
1679
1685
|
|
|
1680
|
-
//
|
|
1681
|
-
|
|
1686
|
+
// DO NOT UPDATE LOCAL STATE HERE - Let realtime DELETE events handle it
|
|
1687
|
+
console.log('✅ Deleted ' + recordsToDelete.length + ' ' + tableName + ' records, waiting for realtime DELETE events to update state');
|
|
1682
1688
|
|
|
1683
1689
|
// Return the count of deleted records
|
|
1684
1690
|
return { count: recordsToDelete.length, error: null };
|
|
@@ -1689,7 +1695,7 @@ export function createSuparismaHook<
|
|
|
1689
1695
|
} finally {
|
|
1690
1696
|
setLoading(false);
|
|
1691
1697
|
}
|
|
1692
|
-
}, [
|
|
1698
|
+
}, []);
|
|
1693
1699
|
|
|
1694
1700
|
/**
|
|
1695
1701
|
* Find the first record matching the filter criteria.
|
package/package.json
CHANGED