Socket
Socket
Sign inDemoInstall

@fluree/fluree-client

Package Overview
Dependencies
Maintainers
9
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fluree/fluree-client - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

2

package.json
{
"name": "@fluree/fluree-client",
"version": "1.0.4",
"version": "1.0.5",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -77,7 +77,4 @@ # Fluree Client SDK for TypeScript/JavaScript

const privateKey = client.generateKeyPair();
client.configure({
privateKey,
signMessages: true,
ledger: 'fluree-jld/387028092978174',
});

@@ -92,2 +89,3 @@ ```

- [transact()](#transact)
- [upsert()](#upsert)
- [history()](#history)

@@ -173,2 +171,50 @@ - [generateKeyPair()](#generateKeyPair)

#### `upsert()`
The `upsert()` method creates a new `TransactionInstance` for upserting with the Fluree database. The `TransactionInstance` can be used & re-used to build, sign, and send upsert transactions to the Fluree instance.
> Upsert is not an API endpoint in Fluree. This method helps to transform an _upsert_ transaction into an _insert/where/delete_ transaction.
>
> Upsert assumes that the facts provided in the transaction should be treated as the true & accurate state of the data after the transaction is processed.
>
> This means that facts in your transaction should be inserted (if new) and should replace existing facts (if they exist on those subjects & properties).
```js
// Existing data:
// [
// { "@id": "freddy", "name": "Freddy" },
// { "@id": "alice", "name": "Alice" }
// ]
const txnInstance = await client.upsert([
{ '@id': 'freddy', name: 'Freddy the Yeti' },
{ '@id': 'alice', age: 25 },
]);
const txnObject = txnInstance.getTransaction();
console.log(txnObject);
// {
// where: [ { '@id': 'freddy', name: '?1' }, { '@id': 'alice', age: '?2' } ],
// delete: [ { '@id': 'freddy', name: '?1' }, { '@id': 'alice', age: '?2' } ],
// insert: [
// { '@id': 'freddy', name: 'Freddy the Yeti' },
// { '@id': 'alice', age: 25 }
// ],
// ledger: ...
// }
const response = await txnInstance.send();
// New data state after txn:
// [
// { "@id": "freddy", "name": "Freddy the Yeti" },
// { "@id": "alice", "name": "Alice", "age": 25 }
// ]
// Note that if this had been an "insert" freddy would now have two names.
// Note also that if this had been handled by deleting/insert, alice might have lost her name.
```
#### `history()`

@@ -627,1 +673,5 @@

```
```
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc