Like it is always the case, I found the solution not so long after asking the question. it appeared that my document was submitted 3 times to the map function. During the first two submits, it correctly emits the expected value. But, on the third call, no value is emitted. As a consequence, the document is removed from the view and no more appears in my query.
Fixing my map function fixed the whole problem. Thanks anyway for your answer. Le mar. 4 juil. 2017 à 20:34, Jens Alfke <[email protected]> a écrit : > > 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 > > 1. Register view and map function > 2. Create document > 3. Query database; get a row from that document > 4. Quit & relaunch app > 5. Re-register map function (?) > 6. 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 > <https://groups.google.com/d/msgid/mobile-couchbase/BF24FE4B-73B1-4702-B8C6-53AB11003DC7%40mooseyard.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- -- Nicolas Delsaux Consultant Mobile: 07 69 99 61 17 <0769996117> Zenika Lille 6 rue Jean Roisin 59000 Lille Standard : +33(0)3 66 72 50 30 <+33(0)366725030> -- 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/CANZq3-FzhKufmOh-U57PWFznb7PYP%2BbXhV03_0VVa1w4C1yggw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
