> On Jul 4, 2017, at 12:47 AM, [email protected] wrote: > > At startup, I try to write a document to Couchbase, and have it published in > a view. > My map function is correctly called but, when i restart the application, the > document doesn't appear in the view.
Are you re-registering the map function on restart? Everything about a view is persistent except the map function. Are you using a legal map function? Remember, it needs to be a “pure” function, i.e the output depends only on the input document, not on any global data or captured variables. Is there anything else (e.g. a pull replication) that might be updating the document later, such that the map function won’t emit anything from it? If you get the document on the second run of the app, does it still have the expected contents? > I've tried to export my application sqlite DB and open it in DBeaver, and the > table mapping the view is empty after I run the application. As a > consequence, and since my map code is called during application run, it seems > to me that the view is not correctly persisted to disk. Any rows you read from a query have been persisted to disk. The view indexer first calls the map function and then writes the emitted rows to the database. The query code reads the rows from the database. There’s no code path that goes from the map function to your query without hitting the database in between. Can you describe the sequence of what happens? It sounds like Register view and map function Create document Query database; get a row from that document Quit & relaunch app Re-register map function (?) Query database; get no results (Actually the order of steps 1 and 2 doesn’t matter.) —Jens -- You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/BF24FE4B-73B1-4702-B8C6-53AB11003DC7%40mooseyard.com. For more options, visit https://groups.google.com/d/optout.
