如何在流星中使用skip()
和limit()
?
Post.find({"user_id":user_id}).skip(0).limit(5);
当我执行上面的服务器时说
调用方法'Userpost'时出现异常TypeError:Object [object Object]没有方法'skip'
答案 0 :(得分:51)
您应该尝试将跳过和限制选项作为对象参数放在 find()
方法中,如下所示:
#conneting to database (works perfect)
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=xxxxxxx\SQLEXPRESS;DATABASE=TestTwitter;UID=;PWD=')
cursor = cnxn.cursor()
#Alter table (works perfect)
cursor.execute("ALTER TABLE TestTable ADD score2 varchar(255);")
#select tweet from each row and calculate score (works perfect)
cursor.execute("SELECT TestTable.Tweet FROM TestTable")
for row in cursor.fetchall():
print (row[0])
sentim = sentiment(row[0])
print (sentim)
#update table and add sentiment score for each row (not so perfect)
cursor.execute("Update TestTable SET score2 = '" + (str(sentim)) + "';")
cnxn.commit()
答案 1 :(得分:6)
以下是有关collection.find([selector], [options])
的文档跳过和限制是查找方法的选项