Created
May 28, 2009 18:16
-
-
Save skeptomai/119478 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remove_field_from_collection(FieldValue, FieldCollectionName, ObjectId) when is_binary(FieldValue) -> | |
case fetch_document(ObjectId) of | |
{true, Document} -> | |
case doc_field(FieldCollectionName, Document) of | |
undefined -> undefined; | |
FieldCollection -> | |
case lists:member(FieldValue, FieldCollection) of | |
true -> | |
UpdatedDocument = erlang_couchdb:set_value(FieldCollectionName, lists:delete(FieldValue, DocFiel), Document), | |
erlang_couchdb:update_document(?OPSCODE_COUCH, ?AUTH_DATABASE, ObjectId, UpdatedDocument); | |
false -> | |
undefined | |
end | |
end | |
end. | |
remove_field_from_collection1(FieldValue, FieldCollectionName, ObjectId) when is_binary(FieldValue) -> | |
try | |
{true, Document} = fetch_document(ObjectId), | |
DocField = doc_field(FieldCollection, Document), | |
UpdatedDocument = erlang_couchdb:set_value(FieldCollectionName, lists:delete(FieldValue, FieldCollection), Document), | |
erlang_couchdb:update_document(?OPSCODE_COUCH, ?AUTH_DATABASE, ObjectId, UpdatedDocument) | |
catch | |
error:_X -> none | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment