Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Code updated for Opa 9.0.1

  • Loading branch information...
commit b3bd8a7dc5f5ae848470dcd7ef9e08dbf61731e3 1 parent ccab951
Cedric Soulas authored
Showing with 12 additions and 16 deletions.
  1. +7 −9 src/admin.opa
  2. +4 −5 src/todo.opa
  3. +1 −2  src/type.opa
16 src/admin.opa
View
@@ -2,16 +2,14 @@ import stdlib.database.mongo
module Admin {
function add_users() {
- dbset(User.t) users = /opado/users;
- // dbset(User.t) users = /opado/users; // with Opa 9.0.1
- users = DbSet.to_list(users)
- // it = DbSet.iterator(users); // with Opa 9.0.1
- List.iter((function(user){
+ dbset(User.t, _) users = /opado/users;
+ it = DbSet.iterator(users);
+ Iter.iter((function(user){
useref = user.ref;
- dbset(Todo.t) items = /opado/todos[ useref == useref ];
- items = DbSet.to_list(items);
- add_user_to_page(user.username, user.fullname, user.is_oauth, List.length(items))
- }), users)
+ dbset(Todo.t, _) items = /opado/todos[ useref == useref ];
+ it = DbSet.iterator(items);
+ add_user_to_page(user.username, user.fullname, user.is_oauth, Iter.count(it))
+ }), it)
}
function add_user_to_page(string username, string fullname, bool is_oauth, int size) {
9 src/todo.opa
View
@@ -31,8 +31,7 @@ module Todo {
exposed @async function db_remove_item(string id) {
useref = User.get_username();
- // Not implemented in Opa 9.0.0 for mongo backend
- // Db.remove(@/opado/todos[~{ id }]);
+ Db.remove(@/opado/todos[~{ id }]);
void
}
@@ -54,9 +53,9 @@ module Todo {
exposed function add_todos() {
useref = User.get_username();
- dbset(Todo.t) items = /opado/todos[ useref == useref];
- items = DbSet.to_list(items);
- List.iter((function(item){add_todo_to_page(item.id, item.value, item.done)}), items)
+ dbset(Todo.t, _) items = /opado/todos[ useref == useref];
+ it = DbSet.iterator(items);
+ Iter.iter((function(item){add_todo_to_page(item.id, item.value, item.done)}), it)
}
function update_todo(string id, string value) {
3  src/type.opa
View
@@ -24,8 +24,7 @@ type Todo.t = {
string created_at
}
-//database opado { // with Opa 9.0.0
-database opado {
+database opado @mongo {
User.t /users[{ref}]
/users[_]/is_oauth = false
Todo.t /todos[{id}]
Please sign in to comment.
Something went wrong with that request. Please try again.