0

I can't seem to persist the data that I'm saving. Whenever the app gets closed, when I open the app again the synced entity from graph doesn't really persist again.

How do you persist and have only one instance of graph and retrieve the previous entity created when you open up the app again?

1 Answer 1

1

Here is the basic setup to persist an Entity of type "User".

// create a user Entity
let user = Entity(type: "User")
user["name"] = "Daniel"
user["age"] = 33

let graph = Graph()

graph.sync()

And searching for your entity:

let graph = Graph()

// setup the search criteria 
let search = Search<Entity>(graph: graph).for(types: "User").where(properties: ("name", "Daniel"))

// synchronously search
let entities = search.sync()

That's it :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.