Key Concept: Just like Unix pipes chain commands to process data, FOAM chains DAOs and streams results to a Sink. Data flows from left to right through decorators, then into the output Sink.
// Sink delegation examplevar sink = PredicatedSink.create({
predicate: someCondition, // Filter in the sinkdelegate: Map.create({
arg1: User.NAME, // Transform (extract name)delegate: ArraySink.create() // Final output
})
});
userDAO.select(sink); // Start the flow
Key Difference:
• DAO Composition (left side): Query specification - describes WHAT data to retrieve and HOW to filter/sort it
• Sink Delegation (right side): Result processing - describes HOW to process the results once retrieved
Think of it as: where/limit/orderBy build the query, select(sink) executes it and streams to the output processor.